[iPhone] 멀티뷰 뷰 전환

시작하세요. 아이폰 프로그래밍 6장 예제

- (IBAction)switchViews:(id)sender

{

    [UIView beginAnimations:@"View Flip" context:nil];

    [UIView setAnimationDuration:1.25];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    

    if (self.yellowViewController.view.superview == nil)

    {

        if (self.yellowViewController == nil)

        {

            YellowViewController *yellowController =

            [[YellowViewController alloc] initWithNibName:@"YellowView" 

                                                   bundle:nil];

            self.yellowViewController = yellowController;

            [yellowController release];

        }

        [UIView setAnimationTransition:

         UIViewAnimationTransitionFlipFromRight

                               forView:self.view cache:YES];

        

        [blueViewController viewWillAppear:YES];

        [yellowViewController viewWillDisappear:YES];

        [blueViewController.view removeFromSuperview];

        [self.view insertSubview:yellowViewController.view atIndex:0];

        [yellowViewController viewDidDisappear:YES];

        [blueViewController viewDidAppear:YES];

    }

    else

    {

        if (self.blueViewController == nil)

        {

            BlueViewController *blueController =

            [[BlueViewController alloc] initWithNibName:@"BlueView" 

                                                 bundle:nil];

            self.blueViewController = blueController;

            [blueController release];

        }

        [UIView setAnimationTransition:

         UIViewAnimationTransitionFlipFromLeft

                               forView:self.view cache:YES];

        

        [yellowViewController viewWillAppear:YES];

        [blueViewController viewWillDisappear:YES];

        [yellowViewController.view removeFromSuperview];

        [self.view insertSubview:blueViewController.view atIndex:0];

        [blueViewController viewDidDisappear:YES];

        [yellowViewController viewDidAppear:YES];

    }

    [UIView commitAnimations];

}

Posted by incree

2012/01/22 19:36 2012/01/22 19:36
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/89

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

Facebook signed request 파싱하는 api가 없어서

http://www.postitcode.com/post/2991875106/facebook-java-parsing-signed-request

요기를 참고해서 만들어 봤다

입맛에 맞게 약간만 수정했음

JSONObject 는 http://www.json.org/java/index.html 여기 api



Posted by incree

2012/01/19 01:12 2012/01/19 01:12
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/88

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[Android] Cookie 버그 - WebView, HttpClient

Android에서 쿠키 공유할때(로그인 Activity -> WebView) 보통 아래와 같은 방법으로 처리한다

01    DefaultHttpClient client;
02     
03    //gets all cookies from the HttpClient's cookie jar
04    List<Cookie> cookies = client.getCookieStore().getCookies();
05     
06            if (! cookies.isEmpty()){
07     
08                CookieSyncManager.createInstance(YourContext.this);
09                CookieManager cookieManager = CookieManager.getInstance();
10     
11                            //sync all the cookies in the httpclient with the webview by generating cookie string
12                for (Cookie cookie : cookies){
13                    
14                    sessionInfo = cookie;
15        
16                        String cookieString = sessionInfo.getName() + "=" + sessionInfo.getValue() + "; domain=" + sessionInfo.getDomain();
17                        cookieManager.setCookie(YOUR_DOMAIN, cookieString);
18                        CookieSyncManager.getInstance().sync();
19                }
20            }
출처 : http://eshyu.wordpress.com/2010/06/27/syncing-cookies-between-an-httpclient-and-a-webview/


위 방식으로 예전에 개발할때는 잘 작동을 했는데,

이번 개발에서는 쿠키가 사라져 버리는 증상이 발생을 했다.

로그는 WebView를 호출한 이후에도 CookieManager에 쿠키가 남아 있었다

WebView에만 cookie가 전달이 안되는 증상이었다.

결론은 Android Cookie에 버그 때문.

Cookie 표준대로 작동안하니 버그라고 해도 될듯


Cookie 생성할때 모든 서브도메인까지 같이 적용되게 하려면

.domain.com 형식으로 도메인을 지정한다(맨 앞에 쩜 중요)


그런데 Android에서 이 형태의 도메인을 인식하지 못한다

2.1, 2.2, 2.3.3 까지 테스트 해 봤지만 모두 처리가 안됐다.

어쩔수 없이 고정 서브 도메인 하나만 지정하는 방법으로 처리했다.


일주일간 고생한걸 생각하면 ㅠㅠ.




p.s : 오늘 미국에 먼일 있나?? 오픈 소스 사이트들이 전부 이상한 안내 메시지 띄워 놓고
접속이 안되게 해놨네. 2011.01.18

Posted by incree

2012/01/18 20:30 2012/01/18 20:30
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/87

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

http://damianflannery.wordpress.com/2010/09/28/android-webview-with-https-loadurl-shows-blankempty-page/

I recently encountered this problem while trying to develop a WebView that is supported on Doughnut (1.6) and above. When presented with a https url the WebView just renders a blank page.

It seems that until Froyo, Android didn’t provide a public API to let you manually decide if you wanted to proceed to an untrusted web site via a WebView.

Note that in this case it is not even that the web site was untrusted (in the conventional sense) – it is because Thawte is not in the default list of trusted certificate authorities on Android. If you use the standard web browser on Android, the browser presents a typical warning dialog (as presented below) that enables you to accept the certificate and carry on.

Invalid certificate warning

If you are using Froyo as the target SDK then you can use:

1engine = (WebView) findViewById(R.id.my_webview);
2engine.setWebViewClient(new WebViewClient() {
3 public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
4 handler.proceed() ;
5 }
6}

However, if you are not using Froyo then it seems you are out of luck. After some research, I concluded that I had the following options:

a) intercept all page requests and forward to external web browser if url begins with https (not a clean or nice user experience and totally unnecessary for Froyo and above)
b) add certificate of website to local keystore (in this case I am serving multiple web pages and the origin of many of these is not known until runtime)
c) make Froyo the minSDK and discard previous versions of Android (not a suitable option)
d) hack and use some private apis (the option described below)

To solve this problem we have to use a private interface (not published on SDK but present in real SDK runtime). As you can see in the Android src tree, the onReceivedSslError is indeed present (and used – it simply cancels the request) in Doughnut. However, this method is not presented to us in the SDK  - it is hidden because it contains a parameter type SslError which is located in a hidden package.  Therefore, we need to copy these src files into our project so that we can access them:

1) Copy WebViewClient.java into the package “android.webkit” within your src folder.
2) Copy SslError.java into the package “android.net.http” within your src folder.

Src files

3) Since we replicated the paths to the src files in the SDK, our code to override onSslError above now works on Android 1.6.

Caution: bear in mind that we are using a private API and Google reserve the right to change private APIs at any time – though in this case it is unlikely since they’ve now made this available in Froyo.

Posted by incree

2011/12/29 10:27 2011/12/29 10:27
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/85

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[iPhone] UIDeviceOrientationDidChangeNotification

http://stackoverflow.com/questions/1500060/view-controller-not-getting-shouldautorotatetointerfaceorientation-messages-on


- (void)viewWillAppear:(BOOL)animated {
   
[super viewWillAppear:animated];

   
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
   
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}

-(void) receivedRotate: (NSNotification *) notification {
   
DebugLog(@"ORIENTATION CHANGE");

   
UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

       
if(interfaceOrientation == UIDeviceOrientationPortrait) {
               
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
               
self.view.bounds = CGRectMake(0, 0, 320, 480);
       
}
       
else if(interfaceOrientation == UIDeviceOrientationLandscapeLeft) {
               
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
               
self.view.bounds = CGRectMake(0, 0, 480, 320);
       
}
       
else if(interfaceOrientation == UIDeviceOrientationLandscapeRight) {
               
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
               
self.view.bounds = CGRectMake(0, 0, 480, 320);
       
}
}

Posted by incree

2011/12/28 23:57 2011/12/28 23:57
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/84

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[Android] 타이틀바 없애기

<application
        android:icon="@drawable/icon"
        android:label="@string/app_
name"
        android:theme="@android:style/Theme.NoTitleBar">


참고 : http://uknowapps.egloos.com/1515393

Posted by incree

2011/11/29 17:34 2011/11/29 17:34
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/73

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

<activity android:name=".youractivity"
                  android:label="@string/app_
name"
                  android:configChanges="orientation|keyboardHidden">


참고 : http://www.androidpub.com/742429

Posted by incree

2011/11/29 17:33 2011/11/29 17:33
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/72

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

nohup grep -RFl -e csex -e cname -e cssnum -e cbirthday -e bwreg -e bwcid * &

Posted by incree

2011/09/29 18:40 2011/09/29 18:40
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/47

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

onpropertychange


Posted by incree

2011/09/28 23:34 2011/09/28 23:34
, , ,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/46

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

[iPhone]주어진 넓이 만큼 문자열 자르기

http://lambert.tistory.com/480
https://gist.github.com/906714


NSString-truncateToSize.h

//
// NSString-truncateToSize
// Fast Fonts
//
// Created by Stuart Shelton on 28/03/2010.
// Copyright 2010 Stuart Shelton.
//
// NSString truncate function for Objective C / iPhone SDK by
// Stuart Shelton is licensed under a Creative Commons Attribution 3.0
// Unported License (CC BY 3.0)
//
// http://creativecommons.org/licenses/by/3.0/
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface NSString (truncateToSize)
- (NSString *)truncateToSize: (CGSize)size withFont: (UIFont *)font lineBreakMode: (UILineBreakMode)lineBreakMode;
- (NSString *)truncateToSize: (CGSize)size withFont: (UIFont *)font lineBreakMode: (UILineBreakMode)lineBreakMode withAnchor: (NSString *)anchor;
- (NSString *)truncateToSize: (CGSize)size withFont: (UIFont *)font lineBreakMode: (UILineBreakMode)lineBreakMode withStartingAnchor: (NSString *)startingAnchor withEndingAnchor: (NSString *)endingAnchor;
@end
NSString-truncateToSize.m
//
// NSString-truncateToSize
// Fast Fonts
//
// Created by Stuart Shelton on 28/03/2010.
// Copyright 2010 Stuart Shelton.
//
// NSString truncate function for Objective C / iPhone SDK by
// Stuart Shelton is licensed under a Creative Commons Attribution 3.0
// Unported License (CC BY 3.0)
//
// http://creativecommons.org/licenses/by/3.0/
//
#import "NSString-truncateToSize.h"
@implementation NSString (truncateToSize)
- (NSString *)truncateToSize: (CGSize)size withFont: (UIFont *)font lineBreakMode: (UILineBreakMode)lineBreakMode {
    return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode withStartingAnchor: nil withEndingAnchor: nil];
} /* (NSString *)truncateToSize: withFont: lineBreakMode: */
- (NSString *)truncateToSize: (CGSize)size withFont: (UIFont *)font lineBreakMode: (UILineBreakMode)lineBreakMode withAnchor: (NSString *)anchor {
    return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode withStartingAnchor: anchor withEndingAnchor: anchor];
} /* (NSString *)truncateToSize: withFont: lineBreakMode: withAnchor: */
- (NSString *)truncateToSize: (CGSize)size withFont: (UIFont *)font lineBreakMode: (UILineBreakMode)lineBreakMode withStartingAnchor: (NSString *)startingAnchor withEndingAnchor: (NSString *)endingAnchor {
    if( !( lineBreakMode & ( UILineBreakModeHeadTruncation | UILineBreakModeMiddleTruncation | UILineBreakModeTailTruncation ) ) )
        return self;
    if( [self sizeWithFont: font].width <= size.width )
        return self;
   
    NSString *ellipsis = @"…";
    // Note that this code will find the first occurrence of any given anchor,
    // so be careful when choosing anchor characters/strings...
    NSInteger start;
    if( startingAnchor ) {
        start = [self rangeOfString: startingAnchor options: NSLiteralSearch].location;
        if( NSNotFound == start ) {
            if( [startingAnchor isEqualToString: endingAnchor] )
                return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode];
            else
                return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode withAnchor: endingAnchor];
        }
    } else {
        start = 0;
    }
   
    NSUInteger end;
    if( endingAnchor ) {
        end = [self rangeOfString: endingAnchor options: NSLiteralSearch range: NSMakeRange( start + 1, [self length] - start - 1 )].location;
        if( NSNotFound == end ) {
            if( [startingAnchor isEqualToString: endingAnchor] )
                // Shouldn't ever occur, since filtered out in block above...
                return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode];
            else
                return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode withAnchor: startingAnchor];
        }
    } else {
        end = [self length];
    }
    NSUInteger targetLength = end - start;
    if( [[self substringWithRange: NSMakeRange( start, targetLength )] sizeWithFont: font].width < [ellipsis sizeWithFont: font].width )
        if( startingAnchor || endingAnchor )
            return [self truncateToSize: size withFont: font lineBreakMode: lineBreakMode];
        else
            return self;
   
    NSMutableString *truncatedString = [[NSMutableString alloc] initWithString: self];
   
    switch( lineBreakMode ) {
        case UILineBreakModeHeadTruncation:
            // Avoid anchor...
            if( startingAnchor )
                start++;
            while( targetLength > [ellipsis length] + 1 && [truncatedString sizeWithFont: font].width > size.width) {
                // Replace our ellipsis and one additional following character with our ellipsis
                NSRange range = NSMakeRange( start, [ellipsis length] + 1 );
                [truncatedString replaceCharactersInRange: range withString: ellipsis];
                targetLength--;
            }
            break;
           
        case UILineBreakModeMiddleTruncation:
        {
            NSUInteger leftEnd = start + ( targetLength / 2 );
            NSUInteger rightStart = leftEnd + 1;
            if( leftEnd + 1 <= rightStart - 1 )
                break;
           
            // leftPre and rightPost consist of any characters before and beyond
            // any specified anchor(s).
            // left and right are the two halves of the string to be truncated - although
            // the initial split is still performed based upon the length of the
            // (sub)string to be truncated, so we could still make a bad initial split given
            // a short string with predominantly narrow characters on one side and wide
            // characters on the other.
            NSString *leftPre = @"";
            if( startingAnchor )
                leftPre = [truncatedString substringWithRange: NSMakeRange( 0, start + 1 )];
            NSMutableString *left = [NSMutableString stringWithString: [truncatedString substringWithRange: NSMakeRange( ( startingAnchor ? start + 1 : start ), leftEnd - start )]];
            NSMutableString *right = [NSMutableString stringWithString: [truncatedString substringWithRange: NSMakeRange( rightStart, end - rightStart )]];
            NSString *rightPost = @"";
            if( endingAnchor )
                rightPost = [truncatedString substringWithRange: NSMakeRange( end, [truncatedString length] - end )];
           
            /* NSLog( @"pre '%@', left '%@', right '%@', post '%@'", leftPre, left, right, rightPost ); */
            // Reassemble substrings
            [truncatedString setString: [NSString stringWithFormat: @"%@%@%@%@%@", leftPre, left, ellipsis, right, rightPost]];
           
            while( leftEnd > start + 1 && rightStart < end + 1 && [truncatedString sizeWithFont: font].width > size.width) {
                CGFloat leftLength = [left sizeWithFont: font].width;
                CGFloat rightLength = [right sizeWithFont: font].width;
               
                // Shorten string of longest width
                if( leftLength > rightLength ) {
                    [left deleteCharactersInRange: NSMakeRange( [left length] - 1, 1 )];
                    leftEnd--;
                } else { /* ( leftLength <= rightLength ) */
                    [right deleteCharactersInRange: NSMakeRange( 0, 1 )];
                    rightStart++;
                }
               
                /* NSLog( @"pre '%@', left '%@', right'%@', post '%@'", leftPre, left, right, rightPost ); */
                [truncatedString setString: [NSString stringWithFormat: @"%@%@%@%@%@", leftPre, left, ellipsis, right, rightPost]];
            }
        }
            break;
           
        case UILineBreakModeTailTruncation:
            while( targetLength > [ellipsis length] + 1 && [truncatedString sizeWithFont: font].width > size.width) {
                // Remove last character
                NSRange range = NSMakeRange( --end, 1);
                [truncatedString deleteCharactersInRange: range];
                // Replace original last-but-one (now last) character with our ellipsis...
                range = NSMakeRange( end - [ellipsis length], [ellipsis length] );
                [truncatedString replaceCharactersInRange: range withString: ellipsis];
                targetLength--;
            }
            break;
    }
   
    NSString *result = [NSString stringWithString: truncatedString];
    [truncatedString release];
    return result;
} /* (NSString *)truncateToSize: withFont: lineBreakMode: withStartingAnchor: withEndingAnchor: */
@end

Posted by incree

2011/09/17 04:56 2011/09/17 04:56
,
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/34

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

« Previous : 1 : ... 10 : 11 : 12 : 13 : 14 : 15 : Next »

Notices

Archives

Authors

  1. incree

Recent Trackbacks

Calendar

«   2018/12   »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

Site Stats

Total hits:
508456
Today:
240
Yesterday:
319