Giter Club home page Giter Club logo

Comments (11)

Kjuly avatar Kjuly commented on July 17, 2024

Thanks you, but what's the version of your SDK? iOS 5.0 at least. :)

from ipokemon.

Kjuly avatar Kjuly commented on July 17, 2024

And hi @ultragtx , can you paste your crash log here, please?

from ipokemon.

ultragtx avatar ultragtx commented on July 17, 2024

you should remove your session by delete and reinstall the app and you will see how it crash at launch

from ipokemon.

ultragtx avatar ultragtx commented on July 17, 2024

oh,seems that simply delete the app cannot clear the session

from ipokemon.

Kjuly avatar Kjuly commented on July 17, 2024

What's session? Do you mean the app content?

from ipokemon.

ultragtx avatar ultragtx commented on July 17, 2024

Google OAuth
在 2013-1-20,下午7:35,Kaijie Yu [email protected] 写道:

What's session? Do you mean the app content?


Reply to this email directly or view it on GitHub.

from ipokemon.

Kjuly avatar Kjuly commented on July 17, 2024

Sorry @ultragtx, I tried several times but without any crash issue at -[UINavigationBar viewCount]... :?

Your crash might occurs in the message below ( CustomNavigationController.m ):

- (void)pushViewController:(UIViewController *)viewController
                        animated:(BOOL)animated {
  ...
  // If |viewCount| == 2, add |backButton| for previous view
  if (++((CustomNavigationBar *)self.navigationBar).viewCount == 2)
    [(CustomNavigationBar *)self.navigationBar addBackButtonForPreviousView];
  ...
}

Here the navigationBar is a CustomNavigationBar, so it'll crash if you push vc (by sending -pushViewController:animated: message) before the custom navigationBar is initialized correctly, cause the default navigationBar does not have the viewCount property.

And if you put a log in -initWithRootViewController: of CustomNavigationController.m, you'll find that: When you send -initWithRootViewController:, it'll send -init first.

So just use -initWithRootViewController: to initialize your navigation controller is fine.


B.t.w, you can refresh your session in this way: Logout in "Settings View" & re-login via VPN or SSH (in CN).

from ipokemon.

ultragtx avatar ultragtx commented on July 17, 2024

Log:
2013-01-20 23:21:21:743 iPokeMon[2271:2311] -[AppDelegate application:didFinishLaunchingWithOptions:] [Line 45] Register Defaults From Settings.bundle...
2013-01-20 23:21:21:795 iPokeMon[2271:2311] -[AppDelegate persistentStoreCoordinator] [Line 232] >>> storePath: /var/mobile/Applications/15F613D1-E7B1-4851-8B48-A48634E53C46/Documents/Pokemon.sqlite3 ---
2013-01-20 23:21:22:013 iPokeMon[2271:2311] TestFlight: Started Session
2013-01-20 23:21:22:351 iPokeMon[2271:2311] TestFlight: Crash Handlers are installed
2013-01-20 23:21:22:466 iPokeMon[2271:2311] -[OAuthManager isSessionValid] [Line 102] CHECKING SESSION...
2013-01-20 23:21:22:475 iPokeMon[2271:2311] -[OAuthManager isSessionValid] [Line 105] INVALID SESSION...
2013-01-20 23:21:22.603 iPokeMon[2271:907] -[UINavigationBar viewCount]: unrecognized selector sent to instance 0x1e513800

Strange behavior, Code run this way

CustomNavigationController.m

  • (id)initWithRootViewController:(UIViewController *)rootViewController {
    #1 self = [super initWithRootViewController:rootViewController];
    #2 if (self) {
    }
    return self;
    }

  • (void)pushViewController:(UIViewController *)viewController
    animated:(BOOL)animated {
    // Set original |backButton| hidden to show custom |backButton|
    #3 [viewController.navigationItem setHidesBackButton:YES];

    // If |viewCount| == 2, add |backButton| for previous view
    #4 if (++((CustomNavigationBar *)self.navigationBar).viewCount == 2)
    [(CustomNavigationBar *)self.navigationBar addBackButtonForPreviousView];
    ...

I set several break point, stopped at #1 >> #3 >> #4(crash) but did not stop at #2, wonder why pushViewController:animated can be called by [super initWithRootViewController:]

Also, the crash can be repeated both on a device and the simulator, but when I fix the crash using the method I post, the crash cannot be repeated even I fully reset the simulator. Still crash on the device, because I did not run the modified code on it.

在 2013-1-20,下午10:57,Kaijie Yu [email protected] 写道:

Sorry @ultragtx, I tried several times but without any crash issue at -[UINavigationBar viewCount]... :?

Your crash might occurs in the message below ( CustomNavigationController.m ):

  • (void)pushViewController:(UIViewController *)viewController
    animated:(BOOL)animated {
    ...
    // If |viewCount| == 2, add |backButton| for previous view
    if (++((CustomNavigationBar *)self.navigationBar).viewCount == 2)
    [(CustomNavigationBar *)self.navigationBar addBackButtonForPreviousView];
    ...
    }
    Here the navigationBar is a CustomNavigationBar, so it'll crash if you push vc (by sending -pushViewController:animated: message) before the custom navigationBar is initialized correctly, cause the default navigationBar does not have the viewCount property.

And if you put a log in -initWithRootViewController: of CustomNavigationController.m, you'll find that: When you send -initWithRootViewController:, it'll send -init first.

So just use -initWithRootViewController: to initialize your navigation controller is fine.

B.t.w, you can refresh your session in this way: Logout in "Settings View" & re-login via VPN or SSH (in CN).


Reply to this email directly or view it on GitHub.

from ipokemon.

Kjuly avatar Kjuly commented on July 17, 2024

Yes, it's so weird...

BreakPoint #2 will be focused last, and -init will be dispatched in BreakPoint #1.

About -initWithRootViewController:, it said:

This is a convenience method for initializing the receiver and pushing a root view controller onto the navigation stack. Every navigation stack must have at least one view controller to act as the root.

So it'll do the initialization job (send -init) before pushing root vc (send -pushViewController:animated:).


My Log looks like this:

2013-01-20 23:52:02:813 iPokeMon[9596:90371] TestFlight: Started Session
2013-01-20 23:52:02:853 iPokeMon[9596:90371] TestFlight: Crash Handlers are installed
2013-01-20 23:52:02:879 iPokeMon[9596:90371] -[OAuthManager isSessionValid] [Line 102] CHECKING SESSION...
2013-01-20 23:52:02:886 iPokeMon[9596:90371] -[OAuthManager isSessionValid] [Line 105] INVALID SESSION...
2013-01-20 23:52:02:911 iPokeMon[9596:90371] -[CustomNavigationController init] [Line 23] ......INIT......
2013-01-20 23:52:02:935 iPokeMon[9596:90371] -[CustomNavigationBar setBackToRootButtonToHidden:animated:] > > [Line 135] --- |CustomNavigationBar|: hide navigation bar...


Does your -init like this right now?

- (id)init {
  self = [super initWithNibName:nil bundle:nil];
  if (self) {
    NSLog(@"......INIT......");
    CustomNavigationBar * customNavigationBar = [CustomNavigationBar alloc];
    [customNavigationBar initWithFrame:CGRectMake(0.f, 0.f, kViewWidth, kNavigationBarHeight)];
    customNavigationBar.delegate = self;
    [self setValue:customNavigationBar forKey:@"navigationBar"];
    [customNavigationBar release];
    [self setNavigationBarHidden:YES];
  }
  return self;
}

from ipokemon.

Kjuly avatar Kjuly commented on July 17, 2024

I found the key issue:

In iOS6.0 -initWithRootViewController: will not send -init message.

So as a fix, you can just do the navigation bar setting job before -initWithRootViewController:.

- (id)initWithRootViewController:(UIViewController *)rootViewController {
  [self _setupNavigationBar];
  self = [super initWithRootViewController:rootViewController];
  if (self) {
  }
  return self;
}

...

- (void)_setupNavigationBar {
  CustomNavigationBar * customNavigationBar = [CustomNavigationBar alloc];
  [customNavigationBar initWithFrame:CGRectMake(0.f, 0.f, kViewWidth, kNavigationBarHeight)];
  customNavigationBar.delegate = self;
  [self setValue:customNavigationBar forKey:@"navigationBar"];
  [customNavigationBar release];
  [self setNavigationBarHidden:YES];
}

from ipokemon.

Kjuly avatar Kjuly commented on July 17, 2024

You can pull my commits on dev branch right now. :)

from ipokemon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.