opfo / app

An iOS app for the EDA397 course made at Chalmers in the spring of 2013.
7 stars 1 forks source link

Going back to a tab when it is showing a nested navigation stack causes an auto layout exception #19

Open rastersize opened 11 years ago

rastersize commented 11 years ago

The app crashes halts at a debug exception the second time the “My Profile” tab is shown.

Steps to reproduce

  1. Tap “My Profile” tab.
  2. Tap on any other tab.
  3. Tap “My Profile” tab again.
  4. Crash

    The crash

The crash occurs in the -[AKTabBarView setContentView:] method on line 47 due to some contradicting auto layout constraints in the OPFUserProfileViewController.

2013-05-01 16:07:43.868 Code Stream[96082:c07] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x13c54f20 h=--& v=--& H:[UITableViewCell:0xa246ed0(0)]>",
    "<NSLayoutConstraint:0x13c4bac0 UIWebView:0xa26f620.leading == UITableViewCell:0xa246ed0.leading + 10>",
    "<NSLayoutConstraint:0x13c50280 UITableViewCell:0xa246ed0.trailing == UIWebView:0xa26f620.trailing + 10>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x13c50280 UITableViewCell:0xa246ed0.trailing == UIWebView:0xa26f620.trailing + 10>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

Possible fixes

/cc @tdeekens

tdeekens commented 11 years ago

I know, i knew your'd see it. The my profile view is @makxan view.

makxan commented 11 years ago

It seems like there is a problem with the constraints that belongs to the UIWebview. At the moment I don't know why the error shows up the second time and not the first time when clicking on "My Profile", but we can look at the problem tomorrow.

makxan commented 11 years ago

The same problem appears when viewing a question a second time.

Steps to reproduce

  1. Go to a question in the Questions-view
  2. Click on another tab
  3. Click on the Questions-tab again
  4. Crash.
rastersize commented 11 years ago

That’s in the OPFQuestionHeaderView. A possible fix could be to disable automatic translation of auto resizing masks with (e.i. theView.translatesAutoresizingMaskIntoConstraints = NO). Might introduce other issues though if there are views which do not have any auto layout constraints.

On May 1, 2013, at 16:50, Marcus Johansson notifications@github.com wrote:

The same problem appears when viewing a question a second time.

Steps to reproduce

Go to a question in the Questions-view Click on another tab Click on the Questions-tab again Crash. — Reply to this email directly or view it on GitHub.

rastersize commented 11 years ago

This issue isn’t resolved as far as I know? Still occurs in master for me (exact same steps to reproduce as previously). @makxan

makxan commented 11 years ago

Well, on my computer no crash or error message was produced so that's why I thought it had been resolved :/

rastersize commented 11 years ago

One way to solve this issue, as it seems to be caused by AKTabBarController being incompatible with auto layout, is to make AKTabBarController behave when used with auto layout. Another way would be to change all our views to use springs and struts instead.

makxan commented 11 years ago

Right now I feel that we shouldn't change so much in the app since we will present it on thursday. The app is still working when the crash occurs and as long as we don't show them the console when we run the app we should be fine :)