UIActionsheet 方向问题
我正在研究使用 pickerview 的操作表的方向。它在纵向模式下运行良好,但在横向模式下不起作用。我可以知道我哪里错了吗?
问候, 萨蒂什
- (IBAction)openActionSheet
{
UIView *ui_pickerview = [[[UIView alloc] initWithFrame:CGRectMake(0, 160, 320, 305)] autorelease];
pickerViewPopup = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIImageView *pickerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,213)];
pickerImageView.image = [UIImage imageNamed:@"picker.png"];
UIImageView *homeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5,137,30,24)];
homeImageView.image = [UIImage imageNamed:@"picker_icon_home.png"];
m_pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,44,0,0)];
m_pickerView.delegate = self;
//m_pickerView.dataSource = self;
m_pickerView.showsSelectionIndicator = NO;
//pickerView.
pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleDefault;
pickerToolbar.tintColor = [UIColor colorWithRed:134/255.0 green:187/255.0 blue:34/255.0 alpha:1];
[pickerToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(DonePicker:)];
[barItems addObject:doneBtn];
[doneBtn release];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
[flexSpace release];
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(closePicker:)];
[barItems addObject:cancelBtn];
[cancelBtn release];
[pickerToolbar setItems:barItems animated:YES];
[barItems release];
[pickerViewPopup addSubview:pickerToolbar];
[pickerViewPopup addSubview:m_pickerView];
//[pickerViewPopup addSubview:pickerImageView];
[pickerImageView release];
//[pickerViewPopup addSubview:homeImageView];
[homeImageView release];
[pickerViewPopup showInView:ui_pickerview];
[pickerViewPopup setBounds:CGRectMake(0,0,320, 464)];
}
I am working on orientation of actionsheet with pickerview. It is working finely on potrait mode but it is not working on landscape mode. May I know where i went wrong?
Regards,
sathish
- (IBAction)openActionSheet
{
UIView *ui_pickerview = [[[UIView alloc] initWithFrame:CGRectMake(0, 160, 320, 305)] autorelease];
pickerViewPopup = [[UIActionSheet alloc] initWithTitle:@""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
UIImageView *pickerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,44,320,213)];
pickerImageView.image = [UIImage imageNamed:@"picker.png"];
UIImageView *homeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5,137,30,24)];
homeImageView.image = [UIImage imageNamed:@"picker_icon_home.png"];
m_pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,44,0,0)];
m_pickerView.delegate = self;
//m_pickerView.dataSource = self;
m_pickerView.showsSelectionIndicator = NO;
//pickerView.
pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleDefault;
pickerToolbar.tintColor = [UIColor colorWithRed:134/255.0 green:187/255.0 blue:34/255.0 alpha:1];
[pickerToolbar sizeToFit];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(DonePicker:)];
[barItems addObject:doneBtn];
[doneBtn release];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
[barItems addObject:flexSpace];
[flexSpace release];
UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(closePicker:)];
[barItems addObject:cancelBtn];
[cancelBtn release];
[pickerToolbar setItems:barItems animated:YES];
[barItems release];
[pickerViewPopup addSubview:pickerToolbar];
[pickerViewPopup addSubview:m_pickerView];
//[pickerViewPopup addSubview:pickerImageView];
[pickerImageView release];
//[pickerViewPopup addSubview:homeImageView];
[homeImageView release];
[pickerViewPopup showInView:ui_pickerview];
[pickerViewPopup setBounds:CGRectMake(0,0,320, 464)];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有将 UIActionSheet 添加到处理横向方向的视图控制器,则 UIActionSheet 将以纵向显示。
If you are not adding your UIActionSheet to a view controller that is handling the orientation for landscape, then the UIActionSheet will come up in portrait.