UIPopoverController 使用 UINavigationBar中添加左箭頭返回按鈕

-(void) onSetting:(id) sender {
 
    SplitBaseController *detail = [[SettingServerController alloc] init];
 
    CGRect frame = [(UIView *)sender frame];
    frame.origin.y = 0;
 
    UIPopoverController *popwin = [[UIPopoverController alloc] initWithContentViewController:detail];
    [popwin setPopoverContentSize:CGSizeMake(400, 300) animated:YES];
    popwin.delegate = self;
    [popwin presentPopoverFromRect: frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
 
    [detail release];
在UINavigationBar中添加左箭頭返回按鈕
在iPhone裏面最討厭的控件之一就是 UINavigationBar了。這個控件樣式修改不方便,連添加按鈕也特別麻煩。下面的例子是如何手動添加帶箭頭的按鈕:
UINavigationItem *item = [navBar.items objectAtIndex:0];
UINavigationItem *back = [[UINavigationItem alloc] initWithTitle:@"Back"];
NSArray *items = [[NSArray alloc] initWithObjects:back,item,nil];
[navBar setItems:items];
 
- (BOOL)navigationBar:(UINavigationBar *)navigationBar
shouldPopItem:(UINavigationItem *)item{
//在此處添加點擊back按鈕之後的操作代碼
return NO;
}

(void) onSetting:(id) sender {
 
    SplitBaseController *detail = [[SettingServerController alloc] init];
 
    CGRect frame = [(UIView *)sender frame];
    frame.origin.y = 0;
 
    UIPopoverController *popwin = [[UIPopoverController alloc] initWithContentViewController:detail];
    [popwin setPopoverContentSize:CGSizeMake(400, 300) animated:YES];
    popwin.delegate = self;
    [popwin presentPopoverFromRect: frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
 
    [detail release];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章