gpt4 book ai didi

iphone - 无法在参数传递中将 'UIBarButtonItemStyle' 转换为 'UIBarButtonSystemItem'

转载 作者:行者123 更新时间:2023-12-03 20:54:39 25 4
gpt4 key购买 nike

我正在尝试使用以下代码添加包含 uipickerview 和“完成”按钮的 subview

    pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0,744, 768, 216)];
mytab = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 700, 768, 44)];

pickerView.alpha=0.0;
mytab.alpha=0.0;


pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;

[self.view addSubview:pickerView];
[self.view bringSubviewToFront:pickerView];


mytab.tintColor=[UIColor blackColor];

UIBarButtonItem * bt1=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStylePlain target:self action:@selector(_cancel)];
UIBarButtonItem * flx=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];

NSArray *arr=[[NSArray alloc] initWithObjects:flx,bt1,nil];
[mytab setItems:arr];
[self.view addSubview:mytab];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
pickerView.alpha=1.0;
mytab.alpha=1.0;
[UIView commitAnimations];


[pickerView release];
[mytab release];
[bt1 release];
[flx release];
[arr release];

它引发以下错误

无法在参数传递中将“UIBarButtonItemStyle”转换为“UIBarButtonSystemItem”

解决这个问题的任何建议

最佳答案

typedef enum {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
#if __IPHONE_3_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIBarButtonSystemItemUndo,
UIBarButtonSystemItemRedo,
#endif
#if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED
UIBarButtonSystemItemPageCurl,
#endif
} UIBarButtonSystemItem;

UIBarButtonItemStylePlain 不适用于 UIBarButtonSystemItem。它可用于 UIBarButtonItemStyle

typedef enum {
UIBarButtonItemStylePlain, // shows glow when pressed
UIBarButtonItemStyleBordered,
UIBarButtonItemStyleDone,
} UIBarButtonItemStyle;

您可以尝试 - (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action; 为您的按钮

关于iphone - 无法在参数传递中将 'UIBarButtonItemStyle' 转换为 'UIBarButtonSystemItem',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5866200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com