有两个UIBarButtonItem想要将它作为一个UIBarButtonItem并在它们之间切换
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
target:self
action:@selector(playaudio:)];
systemItem1.style = UIBarButtonItemStyleBordered;
UIBarButtonItem *systemItem2 = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemPause
target:self
action:@selector(pause:)];
systemItem2.style = UIBarButtonItemStyleBordered;
// flex item used to put space in between buttons
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
//Add buttons to the array
NSArray *toolbarItems = [NSArray arrayWithObjects: settingsButton, flexItem, systemItem, flexItem, systemItem1,flexItem, systemItem2, flexItem, systemItem3, flexItem, modalBarButtonItem, nil];
[toolbar setItems:toolbarItems];
[settingsButton release];
[systemItem release];
[systemItem1 release];
[systemItem2 release];
[systemItem3 release];
[modalBarButtonItem release];
[flexItem release];
-(void) playaudio: …Run Code Online (Sandbox Code Playgroud) 对于UIButton,我现在使用第一个UIButtonTypeCustom我想将其更改为RoundedRect但是当我将UIButtonTypeCustom更改为UIButtonTypeRoundedRect时,它显示白色的RoundedRect而不是为其指定的颜色,并且它还显示了圆形按钮后面的rect按钮框的边缘.所以我想知道如何解决这个问题.
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[myButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
myButton.frame = CGRectMake(0, 0, 60, 30);
[myButton setTitle:@"Done" forState:UIControlStateNormal];
myButton.backgroundColor = [UIColor colorWithHue:1.0/12 saturation:2.0/3 brightness:4.0/10 alpha:1.0];
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView:myButton];
[[self navigationItem] setLeftBarButtonItem:button animated:YES];
Run Code Online (Sandbox Code Playgroud)
感谢帮助.
我有一个问题,因为上半个小时.UIButton 我正在使用,我想UIPopovercontroller在它上面显示.但它崩溃了touchUpinside action.我知道如果我使用我们可以轻松完成UIBarButton但我有一些UI specification这就是为什么我不能使用UIBarButton和UIToolbar.
所以,如果有人有任何想法UIPopovercontroller,UIButton那么请帮助我.帮助将是appriciated.
如何才能使我的应用始终处于纵向模式.如果我旋转iPhone,它不应该以横向模式显示应用程序.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortrait);
return YES;
}
Run Code Online (Sandbox Code Playgroud)
在此编码后我旋转iPhone应用程序以横向模式显示.如何让应用程序始终处于纵向模式.
我在UIToolbar上玩UIBarButtonItem.我想让风格与众不同.因为它是系统项目,有没有办法使它成为边界风格?
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(play:)];
Run Code Online (Sandbox Code Playgroud) 在fastpdfkit中有这样的委托声明
@interface BookmarkViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
//Delegate to get the current page and tell to show a certain page. It can also be used to
// get a list of bookmarks for the current document.
NSObject<BookmarkViewControllerDelegate> *delegate;
}
@property (nonatomic, assign) NSObject<BookmarkViewControllerDelegate> *delegate;
@synthesize delegate;
Run Code Online (Sandbox Code Playgroud)
因为我使用ARC所以委托的声明是这样的
@interface BookmarkViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
id __unsafe_unretained <BookmarkViewControllerDelegate> delegate;
}
@property (unsafe_unretained) id <BookmarkViewControllerDelegate> delegate;
@synthesize delegate;
Run Code Online (Sandbox Code Playgroud)
这是正确的原因当即时调试我得到
currentPage NSUInteger 0
delegate objc_object * 0x00000000
Run Code Online (Sandbox Code Playgroud)