2011-09-13 7 views
1

는 :사용자 지정 탐색 컨트롤

http://reederapp.com/ipad/

특히 나는 왼쪽에있는 탐색을 가지고 비슷한 레이아웃을 사용하고 싶습니다.

어떻게하면됩니까? 그냥 왼쪽에있는 표준 탐색 컨트롤러입니까? 항목/축소판의 레이아웃이 사용자 정의 된 테이블보기입니까? 고마워.

답변

0

표준 탐색 컨트롤러가 아닙니다. 옆에 붙이는 UIView을 직접 만들고 AutoresizingMask 속성을 UIViewAutoresizingFlexibleHeight으로 설정해야합니다. -drawRect:-layoutSubviews: 방법을 사용하여 원하는 단추가있는보기를 설정하십시오. 얼마나 많은 추상화를 사용자 정의보기로 할 것인지에 따라 모든 버튼이 UIView에 메시지를 보내면 해당보기는 해당 메시지를 대리인에게 전달합니다.

예 :

맞춤 테이블 뷰 (여기서는 또는 그리드보기) 인 섬네일로서는
@protocol SideNavigationBarDelegate 
- (void)didTapButtonAtIndex:(NSUInteger)buttonIndex; 
@end 

@interface SideNavigationBar : UIView 
@property (strong, nonatomic) id<SideNavigationBarDelegate> delegate; 

- (id)initWithDelegate:(id<SideNavigationBarDelegate>)aDelegate; 

- (void)addButtonWithIcon:(UIImage *)icon; 

- (void)removeButtonAtIndex:(NSUInteger)index; 

@end 

@implementation SideNavigationBar 
... 
- (id)initWithDelegate:(id<SideNavigationBarDelegate>)aDelegate { 
... 
    [self setDelegate:aDelegate]; 
    [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; 
    [self setFrame:CGRectMake(0.0f, 0.0f, 44.0f, [UIScreen mainScreen].bounds.size.height])]; 
... 
} 

- (void)addButtonWithIcon:(UIImage *)icon { 
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 44.0f, 44.0f)]; 
UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 44.0f, 44.0f)]; 
[iconView setContentMode:UIViewContentModeScaleAspectFill]; 
[iconView setImage:icon]; 
[button addSubview:iconView]; 
...set the target and action for the button... 
[[self buttons] addObject:button]; 
} 

- (void)drawRect:(CGRect)rect { ...draw buttons on view... } 

@end 

. 직접 작성하는 대신 다음을 살펴보십시오. https://github.com/AlanQuatermain/AQGridView