How to access MPMediaPickerController navigationController? - ios

I want to be able to access the navigationController of MPMediaPickerController so that I can change 'navigationController.tabBarController.selectedIndex'. However it seems like I cannot access it. In iOS 7, the default tab for a MPMediaPickerController is the Playlists tab, but I want to change it to the Songs tab. I know it's possible because I see other apps like Rise Alarm Clock have done this, but I have no clue how they do it.
Here are the subviews for MPMediaPickerController:
<UIWindow: 0x14e812a0; frame = (0 0; 320 568); gestureRecognizers = <NSArray: 0x14e81a30>; layer = <UIWindowLayer: 0x14e81a80>>
| <UIView: 0x14ed3c10; frame = (0 0; 320 568); layer = <CALayer: 0x14ee8d50>>
| | <_UISizeTrackingView: 0x14d45050; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x14d44d70>>
| | | <_UIRemoteView: 0x14d446c0; frame = (0 0; 320 568); transform = [0.5, -0, 0, 0.5, -0, 0]; userInteractionEnabled = NO; layer = <CALayerHost: 0x14d44020>>

MPMediaPickerController is a subclass of UIViewController, so you can just use the standard view controller methods to access its navigation controller or bar - .navigationController and tabBarController.
If you cannot access it via those methods you should assume the class is designed to not let you have access to them. It may well be possibly to get access to the underlying tab-bar by iterating through the various sub-views of the controller, but this is unadvisable.

Related

iOS touch event bug on ios 14.4

only on iPhone 12 Pro Max iOS 14.4
When I click the back button on navigationBar
the touch event pass to the bottom collectionView cell
Any idea can fix this question?
Here is the hitTest on UIWindow's log when click back button
2021-06-30 15:55:27.724531+0800 FOURTRY[36793:4319245] hit test view ---- <UIButton: 0x7fee71054bb0; frame = (0 44; 44 44); opaque = NO; layer = <CAGradientLayer: 0x600003fb9400>>
2021-06-30 15:55:27.724987+0800 FOURTRY[36793:4319245] hit test view ---- <UIButton: 0x7fee71054bb0; frame = (0 44; 44 44); opaque = NO; layer = <CAGradientLayer: 0x600003fb9400>>
2021-06-30 15:55:27.725386+0800 FOURTRY[36793:4319245] hit test view ---- <UIView: 0x7fee6f72d140; frame = (0 0; 213.5 343.051); gestureRecognizers = <NSArray: 0x60000306f4e0>; layer = <CAGradientLayer: 0x600003fbd540>>
2021-06-30 15:55:27.725702+0800 FOURTRY[36793:4319245] hit test view ---- <UIView: 0x7fee6f72d140; frame = (0 0; 213.5 343.051); gestureRecognizers = <NSArray: 0x60000306f4e0>; layer = <CAGradientLayer: 0x600003fbd540>>
UIView: 0x7fee6f72d140 is the collectionView cell, Why happen this?

Objective c - Get details with the debugger

I try to get more details about objects from the debugger
I see this object:
<UIImageView: 0x7febf0ebcd20; frame = (0 0; 320 568); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7febf0ebce20>>
How can I know what UIImageView the debugger is pointing on?
How can I get more details about this object like the image itself,or if there is an image inside of it etc...?

Hierarchy is different in storyboard and when debugged while app is running

I have used auto-layout and scrollview. I have created hierarchy in storyboard which looks as shown below :
Basically view has scrollview inside it and scrollview has another subview view1 inside it. Rest of the views are under view1.
While debugging one issue I am facing I show that self.scrollView.subviews prints 3 views. Out of them 2 are ImageViews. And those are not subview of scrollview as per the hierarchy in storyboard.
(lldb) po self.scrollView.subviews
<__NSArrayM 0xb66fe80>(
<UIView: 0xb74b110; frame = (0 0; 320 3240); autoresize = RM+BM; layer = <CALayer: 0xb74b170>>,
<UIImageView: 0xb7e61c0; frame = (313 476; 7 3); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0xb7e62a0>>,
<UIImageView: 0xb7e6350; frame = (314.5 3091.5; 3.5 36); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0xb7e6430>>
)
What can be wrong here? Ask for any detail you need.
The UIView on your console is this view
the 2 UIImageView's are the scroll indicators
And one cool thing to debug view hierarchy is recursiveDescription.
po [self.view recursiveDescription]

RootView Controller are shown shorty when state restorating

I use the state restoration offered by the SDK.
I load all my view controllers from the storyboard. The initial view controller shows another view controller modally. Both have a restoration identifier.
The restoration works fine BUT: When I am in the modally presented view controller and press home (save the state). Then reopen the app and state restoration starts the following happens:
For a split second I see the initial view controller and then the screen changes to the modally presented controller which I actually want to see.
Why is this happening? The snapshot in the caches directory does show the correct screen (from the presented view controller).
You can reproduce the issue with this project. Add a breakpoint in the initial view controller's viewDidAppear method and when restoring state, you will see initial view controller's view in the screen and in view hierarchy:
(lldb) po [[UIWindow keyWindow] recursiveDescription]
<UIWindow: 0x155607f0; frame = (0 0; 320 480); autoresize = W+H; gestureRecognizers = <NSArray: 0x15560d20>; layer = <UIWindowLayer: 0x1555f4f0>>
| <UIView: 0x15542ad0; frame = (0 0; 320 480); autoresize = RM+BM; layer = <CALayer: 0x15542a70>>
| | <UIButton: 0x155432d0; frame = (137 269; 46 30); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x15543b30>>
| | | <UIButtonLabel: 0x15663dd0; frame = (0 6; 46 18); text = 'Button'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1566da20>>
| | <_UILayoutGuide: 0x15542b60; frame = (0 0; 0 20); hidden = YES; layer = <CALayer: 0x15542fe0>>
| | <_UILayoutGuide: 0x15541060; frame = (0 480; 0 0); hidden = YES; layer = <CALayer: 0x155410d0>>
If you check view controller hierarchy, modally presented view controller is not in initial view controller presented property:
(lldb) po [[[UIWindow keyWindow] rootViewController] presentedViewController]
nil
and breakpoint is after (theoretically) state restoration. But later it will be set correctly.
That issue seems to happen when working with storyboards where you let the framework call [window makeKeyAndVisible] for you and it is happening after restoration.
If you add next line to application:willFinishLaunchingWithOptions:
[self.window makeKeyAndVisible];
it will fix it.

Frame shifted incorrectly with Autoresizing in iOS7

I'm having an issue with a view using autosizing resizing improperly in iOS7 (but fine in 6). The view initially renders as I'd expect, then I push another view onto the stack. Once I pop back to the original view, a subview that should be anchored on the right sizes itself too large and of the bounds of the superview.
It's a fairly simple view, created in a Storyboard, that includes the following hierarchy:
Scrollview -> View ->ImageView
It uses autosizing masks, which frankly was done because I had issues using autolayout inside the scrollview in this case (don't want to get into that here). The mask for the ImageView is pretty simple:
-
|
_
|-|<->|-|
-
|
-
On initial load, the X coord and width are as follows:
UIScrollView: frame = (0 64; 320 455); clipsToBounds = YES; autoresize
= W+H;
UIView: frame = (0 0; 320 568); autoresize = W+BM
UIImageView: frame = (20 110; 280 50); clipsToBounds = YES; opaque =
NO; autoresize = W;
On subsequent load, it appears as follows
UIScrollView: frame = (0 64; 320 455); clipsToBounds = YES; autoresize
= W+H
UIView: frame = (0 0; 320 568); autoresize = W+BM
UIImageView: frame = (20 160; 320 50); clipsToBounds = YES; opaque
= NO; autoresize = W
The notable difference being, as bolded, the width of the ImageView frame increases to 320, which is the size of it's bounds. Since it is still offset by 20, it ends up running off the screen. Obviously, I would expect it to stay at 280, as it does when this same thing is run in iOS6.
I don't manipulate the view in any way in code, so this should all be tied the autolayout masks. I cannot find anything about others having similar issues.
--

Resources