UIActionsheet 方向问题

发布于 2024-10-03 20:44:57 字数 2304 浏览 4 评论 0原文

我正在研究使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

π浅易 2024-10-10 20:44:57

如果您没有将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文