Action Coin
 


[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 : 이 글에는 트랙백을 보낼 수 없습니다

var cm:ContextMenu = new ContextMenu();
cm.hideBuiltInItems();
var cmi:ContextMenuItem = new ContextMenuItem("인크리");
cmi.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler);
cm.customItems.push(cmi);
this.contextMenu = cm;

function contextMenuHandler(event:ContextMenuEvent) {
    JavascriptUtil.openLink("http://www.incree.com", "_blank");
}

Posted by incree

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

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

[iPhone]삭제시 흔들리는 아이콘

http://undefinedvalue.com/2010/02/05/iphone-sample-code-tiles

iPhone Sample Code: Tiles

As an exercise in using the Core Animation API, I've implemented a little iPhone app that reproduces the behavior of the iPhone home screen's icon reorganization interface. (You know, dragging the wiggly icons around.) You can download my sample code to see how it works. Some descriptions of the highlights follow below.

Screenshot

The source code and Xcode project can be downloaded here: Tiles-v1.0.zip.

Source is also available on GitHub. (If you're a Mercurial user, you may want to grab it from bitbucket.org.)

The primary classes to look at are TilesViewController and Tile. The view controller implements all of the "logic" of the application, while the Tile class has the animations.

An instance of Tile represents one of the icons, and is derived from CAGradientLayer. The gradient layer properties get set to provide a gloss effect for the tiles. Tile also provides a few animations, initiated by calling these methods:

  • appearDraggable: Changes the tile to be partially transparent, and makes it slightly bigger. This is invoked when the user touches a tile.
  • appearNormal: Reverses the effects of appearDraggable. This is invoked when the tile is released.
  • startWiggling: Starts a tile "wiggling", as in the iPhone home screen while in reorganization mode.
  • stopWiggling: Stops the wiggling effect

The TilesViewController class is pretty straightforward. When the user touches a the screen, the touchesBegan method determines which tile was touched, calls its appearDraggable method, and calls other tiles' startWiggling methods.

As the user drags the tile around the screen, the touchesMoved method moves the dragged tile, and moves the other tiles as needed to provide an open space for it. Core Animation takes care of all the zooming around of the icons.

When the user lets go of the tile, the touchesEnded method drops it in place and removes all the animations.

Things I learned from this project:

  • Turning on the masksToBounds property for layers slows things down quite noticeably.
  • When hit-testing layers, you have to use a layer's presentation layer, not a model layer itself.
  • CAGradientLayer is easy to use.

Here are some things I don't understand. (Maybe some smart person can explain.)

  • When hit-testing to see which layer was touched, I had to do both [touch locationInView:view] and [view convertPoint:location toView:nil]. However, when handling touch-moves, I only have to use [touch locationInView:view]. I don't understand why the coordinate systems are (apparently) different.

Coordinate Systems

Thanks for your comment about the different coordinate systems for different device orientation. Had spent lots of time figuring out why I couldn't tap the correct object.

Thanks again!

Saving button position when app terminates

Hi,

It would be interesting to 'save' the position of the buttons so that the next time the app loads, everything is where the user left it.

Any ideas of how you would implement this feature?

UIImage for tiles?

This looks great and I'm going to start experimenting tonight. But perhaps you know the answer before I pull out too much hair. I'd like to modify this to display images (UIImage objects). From a quick look at the code I think I can replace the CAGradientLayers (and not do the gloss manipulation & drawing), but if you have any advice I'd appreciate it.

This is a great example!

I think this is a great example, thanks. Could you provide any insight on using multiple UIViews in interface builder to construct the grid? Similar to the other post "I'd like to modify this to display images (UIImage objects)", but using UIViews. Thanks in advance for any additional help.

Yes, you can create a layer

Yes, you can create a layer and set the contents property to whatever image you want.

Landscap issue

Hello, i have create springborad view like same as , like wiggling,icon arrangement. its working fine when application launch potriate view but when i rotate in Landscan view it display perfectly but frame not set perfectly;

may be portrait and landscape frame are different. i have set Row = 6;Column = 5; in potrait mode and Landscape mode i have set Row = 7;Column = 6;

-(void)GridViewIcon {

[gridView.layer removeFromSuperlayer];
arrayIcon = [[NSMutableArray alloc]init];
NSArray *array = [[NSArray alloc] initWithObjects:@"1.png",@"2.png",@"3.png",.. 26 icon,nil];

arrayIcon = [NSMutableArray arrayWithArray:array];
[array release];

IconCount = [arrayIcon count];
k = 0;

gridView = [[UIView alloc]init];
//[gridView setUserInteractionEnabled:NO];

int gridH,gridW;
for (int row = 0; row <Row; ++row)
{
for (int col = 0; col < Column ; ++col)
{

int index = (row * Column) + col;

CGRect frame = CGRectMake(TILE_MARGIN + col * (TILE_MARGIN + TILE_WIDTH), TILE_MARGIN + row * (TILE_MARGIN + TILE_HEIGHT),
TILE_WIDTH, TILE_HEIGHT);

NSString *APPICON = [arrayIcon objectAtIndex:index];
UIImage *aImage = [UIImage imageNamed:APPICON];

WiggleEffect *objWiggle;
tileFrame[index] = frame;
objWiggle = [[WiggleEffect alloc]init];
objWiggle.tileIndex = index;
tileForFrame[index] = objWiggle;
objWiggle.frame = frame;

objWiggle.backgroundColor = [UIColor colorWithPatternImage:aImage].CGColor;
objWiggle.delegate = self;

[gridView.layer addSublayer:objWiggle];

[objWiggle setNeedsDisplay];
[objWiggle release];

k++;

if(k == arrayIcon.count)
{
[self.view addSubview:gridView];
return;
}
gridW = col * (TILE_MARGIN + 90) + 90;
gridH = (row + 1)*(TILE_MARGIN + 90 ) + 90;

}

gridView.frame= CGRectMake(0, 0, gridW, gridH);
gridView.center=self.view.center;

}

[self.view addSubview:gridView];

}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

touchStartTime = [event timestamp];

//[touches performSelector:@selector(longTap:) withObject:nil afterDelay:1.5];

if(isMoveable)
{

CALayer *hitLayer = [self layerForTouch:[touches anyObject]];
if ([hitLayer isKindOfClass:[WiggleEffect class]])
{

WiggleEffect *tile = (WiggleEffect*)hitLayer;
//NSInteger inte = tile.tileIndex;
heldTile = tile;
touchStartLocation = [[touches anyObject] locationInView:gridView];
heldStartPosition = tile.position;
//titleSelect = tile.tileIndex;

titleSelect = tile.messageTypeId;
heldFrameIndex = [self frameIndexForTileIndex:tile.tileIndex];

[tile moveToFront];
[tile appearDraggable];
}

}
CALayer *hitLayer = [self layerForTouch:[touches anyObject]];
if ([hitLayer isKindOfClass:[WiggleEffect class]])
{
WiggleEffect *tile = (WiggleEffect*)hitLayer;
//titleSelect = tile.tileIndex;
titleSelect = tile.messageTypeId;
}
else
{
titleSelect = 0;
}

}

  • (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {

    //NSLog(@" Touch touchesMoved at %d",[event timestamp]);
    if (heldTile)
    {
    UITouch *touch = [touches anyObject];
    UIView *view = gridView;
    CGPoint location = [touch locationInView:view];
    [self moveHeldTileToPoint:location];
    [self moveUnheldTilesAwayFromPoint:location];
    }
    }

  • (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {

    // Calculate how long touch lasted
    NSTimeInterval touchTimeDuration = [event timestamp] - touchStartTime;
    //NSLog(@" Touch duration: %3.2f seconds",touchTimeDuration);
    if(touchTimeDuration == 0.00)
    {

    if (!isWoggleRunning)
    {
    //NSLog(@" Touch Began at %d",touchStartTime);
    isWoggleRunning = YES;
    isMoveable = YES;
    CALayer *hitLayer = [self layerForTouch:[touches anyObject]];
    if ([hitLayer isKindOfClass:[WiggleEffect class]])
    {
    //UIGestureRecognizer *obj;
    // obj = [[UILongPressGestureRecognizer alloc]init];

    WiggleEffect *tile = (WiggleEffect*)hitLayer;
    //NSInteger inte = tile.tileIndex;
    heldTile = tile;
    touchStartLocation = [[touches anyObject] locationInView:gridView];
    heldStartPosition = tile.position;
    //titleSelect = tile.tileIndex;
    titleSelect = tile.messageTypeId;

    heldFrameIndex = [self frameIndexForTileIndex:tile.tileIndex];

    [tile moveToFront];
    [tile appearDraggable];
    NSLog(@"PRESSED AT %d to START WIGGLE",heldFrameIndex);
    [self startTilesWiggling];

    }

    }
    else
    {
    isMoveable = NO;
    isWoggleRunning = NO;
    [self stopTilesWiggling];
    }

    }

    if (heldTile)
    {
    [heldTile appearNormal];
    heldTile.frame = tileFrame[heldFrameIndex];
    heldTile = nil;
    }

    CALayer hitLayer = [self layerForTouch:[touches anyObject]];
    if ([hitLayer isKindOfClass:[WiggleEffect class]])
    {
    WiggleEffect *tile = (WiggleEffect
    )hitLayer;
    //titleSelect = tile.tileIndex;
    titleSelect = tile.messageTypeId;
    }
    // [self stopTilesWiggling];
    }

  • (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
    {
    // NSLog(@" Touch touchesCancelled at %d",[event timestamp]);
    [self touchesEnded:touches withEvent:event];
    }

Landscap issue

I am using like same as but i added extra functionlit, when i run application in potrarite mode it working fine and i get all title and perfect layer touch, but when i change orientation (Landscape) that time not working proper layer. here is the code please help me out. if it possible.

[gridView.layer removeFromSuperlayer];
arrayIcon = [[NSMutableArray alloc]init];
NSArray *array = [[NSArray alloc] initWithObjects:@"1.png",@"2.png",@"3.png",.. 26 icon,nil];

arrayIcon = [NSMutableArray arrayWithArray:array];
[array release];

IconCount = [arrayIcon count];
k = 0;

gridView = [[UIView alloc]init];
//[gridView setUserInteractionEnabled:NO];

int gridH,gridW;
for (int row = 0; row

Thank you so much!

You just saved me 3 days of work here since im new to the stuff and this is exactly what im looking for!
CAN I PURCHASE YOU A COFFEE OR SO? ANY BOOK AT AMAZONE?


Posted by incree

2011/07/20 19:30 2011/07/20 19:30
Response
0 Trackbacks , 0 Comments
RSS :
http://www.incree.com/tc/incree/rss/response/23

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

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

Notices

Archives

Authors

  1. incree

Recent Trackbacks

Calendar

«   2018/02   »
        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      

Site Stats

Total hits:
445387
Today:
64
Yesterday:
111