-(void) keyboardDidShow:(NSNotification *)notifi
{
if(keyboardVisible)
{
NSLog(@"Keyboard is already visible. Ignoring notification");
return;
}

NSLog(@"Resizing smaller for keyboard");

NSDictionary *info = [notifi userInfo];

NSValue *aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;

CGRect viewFrame = self.view.frames;
viewFrame.size.height -= keyboardSize.height;

scrollView.frame = viewFrame;
keyboardVisible = YES;
}

-(void)keyboardDidHide:(NSNotification *)notifi
{
if(!keyboardVisible)
{
NSLog(@"Keyboard already hidden..");
return;
}

NSLog(@"Resizing bigger with no keyboard");

NSDictionary *info = [notifi userInfo];

NSValue *aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;

CGRect viewFrame = self.view.frames;
viewFrame.size.height += keyboardSize.height;

scrollView.frame = viewFrame;
keyboardVisible = NO;
}

'Object-C' 카테고리의 다른 글

StanFord Lecture PDF  (0) 2010.10.29
테이블뷰 정렬  (0) 2010.10.23
트위터 posting  (0) 2010.10.22
valueForKey vs objectForKey  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:
[NSURL URLWithString:
@"http://YOUR_TWITTER_USERNAME:YOUR_PASSWORD@twitter.com/status/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"status=%@", 
NSURLResponse *response;
NSError *error;
NSData *result = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:&response error:&error];
NSLog(@"%@", [[[NSString alloc] initWithData:result
encoding:NSASCIIStringEncoding] autorelease]);



'Object-C' 카테고리의 다른 글

테이블뷰 정렬  (0) 2010.10.23
키보드 사이즈 이벤트  (0) 2010.10.23
valueForKey vs objectForKey  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
valueForKey 는 코코아에서 키-밸류-코딩 패턴을 위해 사용합니다.

NSDictionary 의 valueForKey를 호출하면 내부적으로 다시 ObjectForKey 를 호출합니다.

 하지만 valueForKey 는 인자로 받는값을 확인하고 키의 종류에 따라서 다르게 동작합니다. 

코코아 바인딩을 하는 경우가 아니라면 이것은 원하는 것이 아닐수도 있습니다. 딕셔너리를 접근하는 올바른 메서드는 ObjectForKey 입니다.

'Object-C' 카테고리의 다른 글

키보드 사이즈 이벤트  (0) 2010.10.23
트위터 posting  (0) 2010.10.22
키보드 사라지게 하기  (0) 2010.10.22
NSNotificationCenter  (0) 2010.10.10
MoviePlayer  (0) 2010.10.09

+ Recent posts