2012-01-11 83 views
1

我用UIImageViews(而不是文本標籤等)創建了水平的UIPickerView。基本上工作正常,除了圖像只顯示在iPhone模擬器,但不是在實際的iPhone。UIImageView在水平UIPicker組件顯示在iPhone模擬器上但不是在實際的iPhone上

我在爲iOS v 4.3版本構建。

我完全難住,一直在努力爭取相當一段時間!

謝謝:)

下面是從代碼的摘錄:

// 
// PickerPicViewController.m 
// PickerPic 
// 
// Created by user on 2012/01/11. 
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. 
// 

#import "PickerPicViewController.h" 

@implementation PickerPicViewController 

@synthesize piccie; 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView 
{ 
    return 1; 
} 

- (NSInteger) pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component 
{ 
    return 2; 
} 

- (UIView *) pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view 
{ 
    UIImage *one = [UIImage imageNamed:@"rss.png"]; 

    UIImageView *oneView = [[[UIImageView alloc] initWithImage:one] initWithFrame:CGRectMake(0, 0, 50, 50)]; 

    return oneView; 
} 


#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 


    piccie = [[UIPickerView alloc] initWithFrame:CGRectZero]; 
    piccie.delegate = self; 
    piccie.dataSource = self; 
    piccie.showsSelectionIndicator = YES; 
    piccie.backgroundColor = [UIColor clearColor]; 


    CGRect pickerFrame = piccie.frame; 
    pickerFrame.size.width = 70; 
    pickerFrame.size.height = 216; 
    pickerFrame.origin.x = 125; 
    pickerFrame.origin.y = 20; 
    piccie.frame = pickerFrame; 

    CGAffineTransform rotate = CGAffineTransformMakeRotation(-M_PI/2); 
    rotate = CGAffineTransformScale(rotate, 1, 1.30); 
    CGAffineTransform t0 = CGAffineTransformMakeTranslation(1, -40.5); 
    piccie.transform = CGAffineTransformConcat(rotate, t0); 

    [self.view addSubview:piccie]; 


} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated 
{ 
    [super viewDidDisappear:animated]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

@end 
+0

確保圖像名稱rss.png,檢查瓶蓋 – 2012-01-11 13:29:14

+0

...然後清潔並重建項目... – Nekto 2012-01-11 13:42:12

+0

感謝您的反饋 - 我仔細檢查了文件名/箱&乾淨的構建,但不幸的是沒有喜悅。 – user1143230 2012-01-11 14:06:58

回答

0

你爲什麼初始化UIImageView的兩倍,同時創造?我認爲這是問題。相反,嘗試

UIImageView *oneView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; 
[oneView setImage: one]; 
相關問題