Я создал горизонтальный UIPickerView с UIImageViews (вместо текстовых меток и т. Д.).В основном работает нормально, за исключением изображений, которые отображаются только на симуляторе 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