The TWTRComposerViewController not showing in Iphone-X Landscape - ios

I'm using TWTRComposerViewController to share video on twitter my landscape app, it is working fine in all other device's except iPhone-X , when i try to share video in iPhone-X then composer not showing and the App freezes out.
I'm using the below written code:
if ([[Twitter sharedInstance].sessionStore hasLoggedInUsers])
{
dispatch_async(dispatch_get_main_queue(), ^{
TWTRComposerViewController *composer = [[TWTRComposerViewController emptyComposer] initWithInitialText:#"Testing" image:nil videoURL:url];
composer.delegate = self;
[self presentViewController:composer animated:true completion:nil];
});
}
else
{
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
if (session) {
dispatch_async(dispatch_get_main_queue(), ^{
TWTRComposerViewController *composer = [[TWTRComposerViewController emptyComposer] initWithInitialText:#"Testing" image:nil videoURL:url];
composer.delegate = self;
[self presentViewController:composer animated:true completion:nil];
});
} else {
NSLog(#"Error");
}
}

The glitch you are encountering with the TWTRComposerViewController is not your error, nor are you the only one dealing with this.
This is a bug in Twitter's SDK.
Looking into Twitter's recent activity / attention to their SDK it seems their interface packages are lagging ever since the new iPhone X release. I would expect this to be resolved sooner than later.
I guess the best temporary solutions would be to either force your controller into portrait mode during this process, disable rotation for the appropriate controllers, or (though perhaps too ugly) present this VC in portrait, and rotate the view. Nonetheless, hopefully Twitter updates their SDK soon.
Report this as a bug to Twitter on their developer forum to let them know about the issue, as they should eventually see the numerous posts of the same issue...

Related

UIImagePickerController captureMode not assigning correctly

I'm using UIImagePickerController to take pictures and videos from my app. Toggling between the two isn't too bad. If the user chooses to record a video, I first check this:
if (picker.cameraCaptureMode == UIImagePickerControllerCameraCaptureModeVideo)
{
[self captureVideo];
}
else
{
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
[self captureVideo];
}
This usually works totally fine. Here's the catch. I'm also using OpenTok by Tokbox to do video calls, and it seems like the captureMode assignment doesn't work after a video call. It seems completely crazy, but I made this modification to do some debugging:
if (picker.cameraCaptureMode == UIImagePickerControllerCameraCaptureModeVideo)
{
[self captureVideo];
}
else
{
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
if (picker.cameraCaptureMode != UIImagePickerControllerCameraCaptureModeVideo)
{
NSLog(#"Assignment unsuccessful???")
}
[self captureVideo];
}
And i get this "Assignment unsuccessful???" log every single time. UIImagePickerController must not be allowing the assignment or something. I really can't figure it out. I've also made a forum post on OpenTok's site to see if they're possibly not releasing some camera resources, but I don't think it's their problem.
Any insight here?
Use:
+ (NSArray *)availableCaptureModesForCameraDevice:(UIImagePickerControllerCameraDevice)cameraDevice
to check which source types are available. Also if you're using a simulator, it will never assign properly.
Solved with a solution on the TokBox forum. I needed to first change my audio session before trying to access the microphone.
AVAudioSession *mySession = [AVAudioSession sharedInstance];
[mySession setCategory:AVAudioSessionCategorySoloAmbient error:nil];
[self presentViewController:picker animated:YES completion:NULL];

Azure Mobile Services crash

Using the ios WindowsAzureMobileServices.framework (v1.2.3) I get an [NSArray insertObject:atIndex] exception (object cannot be nil) in code I don't control when I use the following code to present a MSLoginController.
MSLoginController *loginController =
[self.client
loginViewControllerWithProvider:provider
completion:^(MSUser *user, NSError *error)
{
//some code
}];
[controller presentViewController:loginController animated:YES completion:nil];
Any one have ideas how to rectify? Or why this is occurring?
I expanded the stack trace when the crash occurs and discovered UIAppearance calls were in the stack when the UIViewController was presented. After some digging into our appearance customization code the following code causes the crash:
[[UIBarButtonItem appearance] setStyle:UIBarButtonItemStylePlain];
The Azure library uses the UIToolbar in a different manner than was used elsewhere in the app and produced the exception.

UIActivityViewController taking long time to present

I made an app for iPhone. Now, I'm recreating it for iPad.
When the user selects the action button in the toolbar, a popover should show with a UIActivityViewController, but for some reason, it's taking about 10 seconds for it to show the first time. On iPhone, it takes about a second. It's the same code except for the popover.
I tried disabling the popover, but it still takes around 10 seconds to show.
Here is the code:
-(IBAction)Actions:(UIBarButtonItem*)sender
{
if ([activityPopover isPopoverVisible] == YES)
{
[activityPopover dismissPopoverAnimated:YES];
return;
}
UIWebView *currentWebView = ((TabView *)self.tabs[self.currentTabIndex]).webViewObject;
NSString *currentURL = (NSString*)[currentWebView request].mainDocumentURL;
if (currentURL == NULL) return;
BookmarkActivity *bookmarkActivity = [[BookmarkActivity alloc] init];
UIActivityViewController *sharing = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObject:currentURL] applicationActivities:#[bookmarkActivity]];
activityPopover = [[UIPopoverController alloc] initWithContentViewController:sharing];
[activityPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
I have tested on my iPad 3 and my iPad mini, both take awhile to present this.
How can I solve the problem?
Good question, I just had the same problem. It is not really solvable. However, you may improve the user experience by creating an activity indicator and then sending the initialization of the UIActivityViewController to the background:
-(void)openIn:(id)sender
{
// start activity indicator
[self.activityIndicator startAnimating];
// create new dispatch queue in background
dispatch_queue_t queue = dispatch_queue_create("openActivityIndicatorQueue", NULL);
// send initialization of UIActivityViewController in background
dispatch_async(queue, ^{
NSArray *dataToShare = #[#"MyData"];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
// when UIActivityViewController is finally initialized,
// hide indicator and present it on main thread
dispatch_async(dispatch_get_main_queue(), ^{
[self.activityIndicator stopAnimating];
[self presentViewController:activityViewController animated:YES completion:nil];
});
});
}
It works like a charm. When the user touches the button, the activity indicator starts animating, thus indicating that the process will take a while.
I was having the same issue on iOS 7. When I removed UIActivityTypeAirDrop from the allowed activity types, however, the controller appears almost instantly.
Although these calls are already from the main thread, since iOS 7, wrapping some of those presentation calls in a dispatch block seems to greatly reduce the delay
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:activityViewController animated:YES completion:nil];
});
Had this issue myself recently. Would sometimes take nearly 4 or 5 seconds to pop up, which is a lifetime! Only the first time though. Subsequent calls were quick.
Also had a similar issue a couple of years back with the keyboard appearing slowly and someone produced a few lines of code added to the appdelegate that preloads the keyboard to get around that.
I used a similar approach here to preload the UIActivityViewController by placing this in the AppDelegate on startup. It's absolutely a hack which shouldn't be necessary but I couldn't find any other options.
let lagfreeAVC:UIActivityViewController = UIActivityViewController(activityItems: ["start"], applicationActivities: nil)
lagfreeAVC.becomeFirstResponder()
lagfreeAVC.resignFirstResponder()

Game Center ViewController not appearing when testing on phone

I'm using iOS6 and my phone is a 4S.
I'm using code from the GKLeaderboards example to get Game Center working and the local player authenticated. This code I've imported into my own Sparrow framework scaffold project.
This seems to work totally fine on the simulator, I get the "welcome back xxxx, ** sandbox mode *" msg.
But when I test it on the actual iPhone, my game (which right now just consists of lots of tiles on the screen) slows down to a crawl, and no Game Center msg appears.
Looking at code, because I'm logged in with a different Game Center account on the phone (i'e not the sandbox one) then I think it's trying to present the log in with new account view, but it's not appearing.
The code I'm using is...
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
// If there is an error, do not assume local player is not authenticated.
if (viewController != nil)
{
[mainViewController presentViewController:viewController animated:NO completion:nil];
//store this view controller pointer
NSLog(#"viewController != nil");
}
else if (localPlayer.isAuthenticated)
{
NSLog(#"Authentication changed: player authenticated.");
}
else
{
NSLog(#"can't log in");
}
}
I think the problem is being caused by this line...
[mainViewController presentViewController:viewController animated:NO completion:nil];
The game doesn't seem to crash but there seems to be something going wrong causing it all to slow right now, any ideas as to what could cause this?
Ok I seem to have gotten this working. Basically I didn't have mainViewController set properly.

The same situation,Second time be rejected because of used MBProgressHUD :(

Reasons for Rejection: The activity indicator spins indefinetely and the user can't access the content
The same situation,Second time be rejected because of used MBProgressHUD.
Who can tell me Uploaded to appstore app would be any different? I done various tests, such a problem did not appear in the local.
-----------------------------in my controller-----------------------------------
- (void)downloadList
{
if (isLoading) {
return;
}
isLoading = YES;
//do something......
//show the progressbar based on MBProgressHUD
[[MyDelegate getAppDelegate] showProgressBarForTarget:self whileExecuting:#selector(showProgressBarForLoading)];
}
}
- (void)showProgressBarForLoading
{
while (isLoading) {
//i++;
continue;
}
}
- (void)downloadListDidReceive:(XGooConnection*)sender obj:(NSObject*)obj
{
//do something......
isLoading = NO;
}
-----------------------------in my AppDelegate-------------------------------
- (void)showProgressBarForTarget:(id)target whileExecuting:(SEL)theSelector
{
UIViewController *controller = [splitViewController.viewControllers objectAtIndex:0];
HUD = [[MBProgressHUD alloc] initWithView:controller.view];
[controller.view addSubview:HUD];
HUD.delegate = self;
// Show the HUD while the provided method executes in a new thread
[HUD showWhileExecuting:theSelector onTarget:target withObject:nil animated:YES];
}
-----------------------------Reasons for Rejection detail-------------------------------------
The most recent version of your app has been rejected........
Reasons for Rejection:
The steps to reproduce are:
Launch the app
Select the Menu button at the top left corner
Select a menu item
The activity indicator spins indefinetely and the user can't access the content
First off, the reason for this rejection is likely improper usage of MBProgressHUD, not MBprogressHUD itself.
If this only occurs during app store testing, try running the app in Release configuration. There also might be networking conditions there, that you haven't anticipated. Perhaps this only occurs when there is a network error (airplane mode?). Are you setting isLoading = NO when a network error occurs?
FWIW, there is a much better way to show / hide the HUD for asynchronous requests. Pooling a flag in a while loop like this is extremely inefficient. Look at the NSURLConnection example in the MBProgressHUD demo app.

Resources