네비게이션 컨트롤러가 있는 곳에 타이틀바를 넣고, 오른쪽에 버튼을 추가하는 코드이다.
물론 액션은 위와 같이 정의하고, h파일에 선언하는 것을 잊으면 안된다.
| UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithTitle:@"신청" |
| style:UIBarButtonItemStylePlain target:self action:@selector(apply:)]; |
| self.navigationItem.rightBarButtonItem = settingsButton;
-(void)apply:(id)sender {
}
|
기본 상태에서 웹뷰를 넣으면, 사이트가 원래 크기로 나온다.
[_webView setScalesPageToFit:YES];
위의 코드를 넣어주면, 웹뷰가 화면 크기에 맞게 작아지며, 투 핑거 제스쳐를 이용해 리사이징이 가능하다.
날짜의 형식을 넣는 건 아래와 같다.
| NSString * theDateString; |
| |
| NSDate * aDate; |
| aDate=[[NSDate alloc]init]; |
| |
| NSDateFormatter * aDateFormatter; |
| aDateFormatter=[[NSDateFormatter alloc] init]; |
| [aDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; |
| [aDateFormatter setDateFormat:@"MM-dd-yyyy"]; |
| |
| theDateString=@"01-27-2012"; |
| aDate=[aDateFormatter dateFromString:theDateString]; |
위의 MM-dd-yyyy로 하고, 01-27-2012로 해야 제대로 된 날짜를 얻을 수 있다. mm을 소문자로 쓰면, 모두 1월로 나오거나, 12월로 나오는 어처구니 없는 상황을 겪을 수도 있다.
| NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; |
| //[dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; |
| [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; |
| NSString *articleDateString = [dateFormatter stringFromDate:aDate]; |
활용할 때는 역시 NSDateFormatter를 사용하며 스타일 정의를 통해 위와 같이 NSString으로 빼내면, Jan 27, 2012 식으로 나온다.
주석처리한 setTimeStyle의 경우 시간도 나오게할 수 있다. 값의 정의에 대해서는 아직 쓰지 않아 찾아보지 않았다. 시간도 필요하면, 정의 부터 찾아보면 되겠다. NSDateFormatterMedumStyle은 00:00:00 AM 식으로 나온다.
댓글 달기