IBM Worklight 6.0 - App Center on iOS7 fails to open - ios

After building the IBMAppCenter application with Xcode 5.0.2,
When running the .ipa on an iPhone it unfortunately doesn't work.
When clicking the app it opens up, shows the splash image for a few seconds, but then closes without throwing an error.
Is this a known error?

Make sure that you have followed the instructions on how to enable the AppCenter application for iOS 7, as detailed in the following IBM technote: http://www-01.ibm.com/support/docview.wss?uid=swg27039574
I'd even say to make sure you are running the correct version of Worklight.
Please carefully read the technote.
Copy/paste:
Enable the Application Center Client
Complete the following steps to enable your Application Center Client to run on iOS 7:
Import the App Center project into Eclipse as the documentation states.
Use the Worklight Studio wizard to create another Worklight project and add an iPhone environment.
Copy the apps/appName/iphone/native/WorklightSDK/libWorklightStaticLibProject.a file to the App Center project. Overlay the existing file by using the same name.
Add the following code in the CDVMainViewController Worklight generated class (CDVMainViewController.m). This code handles the iOS 7 status bar design change.
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
- (void)viewWillAppear:(BOOL)animated
{
CGFloat version = [[UIDevice currentDevice].systemVersion floatValue];
if (version >= 7) {
// iOS 7 or above
CGRect oldBounds = [self.view bounds];
CGRect newViewBounds = CGRectMake( 0, -10, oldBounds.size.width,
oldBounds.size.height-20 );
CGRect newWebViewBounds = CGRectMake( 0, -20, oldBounds.size.width,
oldBounds.size.height-40 );
UIColor *headerColor =
[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f];
[self.view setBackgroundColor:headerColor];
[self.view setBounds:newViewBounds];
[self.webView setBounds:newWebViewBounds];
}
[super viewWillAppear:animated];
}

Related

Conditional code for iOS class availability

I am trying to add conditional code to prevent "Symbol not found" errors on an iOS 7 device when using an iOS 8 class, in this case UIBlurEffect:
dyld: Symbol not found: _OBJC_CLASS_$_UIBlurEffect
Even though the code within the conditional does not run (I do not see the "UIBlurEffect will be used!" log statement), I still get the error. If I comment the block out, it runs fine.
BOOL blurAvailable = NSClassFromString(#"UIBlurEffect") ? YES : NO;
if (blurAvailable)
NSLog(#"UIBlurEffect available");
else
NSLog(#"UIBlurEffect not available");
if (navBarBlurBool && blurAvailable)
{
NSLog(#"UIBlurEffect will be used!");
if (![viewController.navigationController.navigationBar viewWithTag:BLUR_NAVBAR_TAG])
{
// Code works on iOS 7 if this block is commented out:
[self storeOriginalNavBarImages];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
blur.userInteractionEnabled = NO;
blur.tag = BLUR_NAVBAR_TAG;
[self.navigationController.navigationBar insertSubview:blur atIndex:0];
}
}
I don't understand - I would assume that if blurAvailable is false then the offending code should not run and I should not get the "Symbol not found" runtime error.
I'm using iOS 9.2 SDK. Xcode 7.2. Deployment target is iOS 7.0.
Please make sure that blurAvailable is really NO on iOS 7.
Maybe the class is available on iOS 7 but not marked as such in the documentation. They might have introduced it in iOS 7 as a private class (just hiding it in the doc and headers).
Try testing another class marked as "unavailable on iOS 7" like UIVisualEffectView.
From a comment in this question, the answer is to add UIKit as an Optional dependency in "Build Phases" -> "Link Binary with Libraries". I can now run the conditional iOS 8 code without errors on the iOS 7 device.

status bar position is not proper when wkWebview plugin is added in iOS phonegap application

I am developing iOs application using phonegap.
phonegap version : 3.5.0
xcode version : 6.1.1
I have added the "org.apache.cordova.statusbar" plugin for the status bar. My application is working fine on iOs 7 & iOs 8. But for better performance in iOs 8, I have added the "com.telerik.plugins.wkwebview" plugin. After adding this plugin, header part of application is destroy and looking that it is inside status bar. I have also attached image with this question. I have added the following property in my_project-info.plist file:
Status bar is initially hidden : NO
View controller-based status bar appearance : YES
You can solve this issue using following steps
1) Go to your project explorer, click on class folder there is file "MainViewController.m", add code
- (BOOL)prefersStatusBarHidden {
return YES;
}
2) Go to your project explorer, click on Resources folder there is file like "Your_project_name-Info.plist" add here as key View controller-based status bar appearance and value YES.
Find the "- (void)viewWillAppear:(BOOL)animated" method from MainViewController.m file and replace the method with following code.
- (void)viewWillAppear:(BOOL)animated
{
// View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
// you can do so here.
//Lower screen 20px on iOS 7 and iOS 8
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7){
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
}
[super viewWillAppear:animated];
}
This solution has worked for me.

EXC_BAD_ACCESS when retrieving views from transition context on iPhone 4

I have the following code, which works perfectly on my iPhone 5 and all the iPhone simulators, but it crashes on my iPhone 4. I get EXC_BAD_ACCESS on the last line where I pass UITransitionContextToViewKey to my transition context.
I have a clean analyze and build, and the same happens for both UITransitionContextFromViewKey and UITransitionContextToViewKey.
My iPhone 4 is on iOS 7.1.2, my deployment target is 7.0, targeted build base SDK 8.0.
Anyone knows what to do here? thx.
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
{
// get transition parameters from context
UIView *containerView = transitionContext.containerView;
UIViewController *destinationViewController =
[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
if ([destinationViewController.title isEqualToString:#"ListController"]) {
// get source and destination views
UIView *sourceViewSnapshot = [self.view snapshotViewAfterScreenUpdates:YES];
UIView *destinationView = [transitionContext viewForKey:UITransitionContextToViewKey]; // EXC_BAD_ACCESS
// ...
}
The viewForKey method is iOS 8 and up, but the viewControllerForKey method is supported in iOS 7. A small change to your code gets the view in iOS 7:
UIView *destinationView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view;
From the documentation:
UITransitionContextToViewKey
Available in iOS 8.0 and later.
You can't run that code on iOS 7
You might want to add runtime system version checks and branch out to a iOS 7 compatible code at this point if you want to maintain compatibility with this version of the system

Basic Request: How to Get Text Input in Cocos2d Application

I have what I thought would be a simple task: create two input fields on a scene and perform the usual input methods on them (touch to set input focus, allow text entry using on-screen keyboard, deselect field when "Done" key is pressed, re-establish input focus if the field is touched/selected again, etc.), basically the usual functionality that you see in most applications that allow user text input.
I have looked through most of the relevant forums for iOS development, especially StackOverflow, and I have only seen incomplete code snippets and vague references, some of which don't even exist anymore.
I thought that this would be a simple task, but everyone seems to think that vague directions are sufficient for someone who just simply wants a straight answer.
Can someone provide a complete description of what needs to be done to accomplish this task?
Thanks.
p.s.: After realizing that I didn't provide complete information, this is the environment and tools that I'm using:
Library Framework: Cocos2D v2
Development Studio: Xcode 5.1
Target Platforms: iOS on iPhone, iPad, and iPod touch devices (port to Android platforms in progress)
Minimum iOS required: 6.1
If you are using Cocos2d v3, use CCTextField for text input. For example:
CCTextField *enterName = [CCTextField textFieldWithSpriteFrame:[CCSpriteFrame frameWithImageNamed:#"textfield_background.png"]];
enterName.fontSize = 16.0f;
enterName.contentSize = CGSizeMake(100.0f, 50.0f);
enterName.preferredSize =CGSizeMake(100.0f, 50.0f);
enterName.positionType = CCPositionTypeNormalized;
enterName.position = ccp(0.5f, 0.5f);
[self addChild:enterName z:5];
If you are using Cocos2d v2, use UIKit components. For example:
CGSize size = [[CCDirector sharedDirector] winSize];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(size.width * 0.5,
size.height* 0.1,
100, 100)];
textField.borderStyle = UITextBorderStyleRoundedRect;
[[[CCDirector sharedDirector] view]addSubview:textField];
As a note, Cocos2d v3 actually uses a UITextField in iOS and a NSTextField in Mac.
#ifdef __CC_PLATFORM_IOS
/** iOS: UITextField used by the CCTextField. */
#property (nonatomic,readonly) UITextField* textField;
#elif defined(__CC_PLATFORM_MAC)
/** Mac: NSTextField used by the CCTextField. */
#property (nonatomic,readonly) NSTextField* textField;
#endif
You can use basic UIView and add it over the cocos2d layers, using this code:
[[[CCDirector sharedDirector] view] addSubview:yourCustomView];

ios 6 and ios 7 incosistance in view

as we know in iOS 7 the status bar overlaps with a view but not in iOS 6 .
I developed whole application for iOS7 and now I being asked to make iOS6 support for it
but it is just a mess.
as we see in this Overlaps the status bar on view iOS7 question there is solution for iOS 7 to be like iOS6
but can I make it opposite way ? and somehow make iOS 6 behave like iOS7 with status bars ?
You can't make iOS 6 status bar act like iOS 7 status bar they are completely different designs. iOS 7 uses a flat UI whilst iOS 6 doesn't. Have a read through the iOS 7 transition guide for a better understanding and how to handle the differences.
To be specific towards the Status bar here is the section of that document that tells you how to handle it.
Short Answer: No you can't.
iOS 6 SDK does not let you to control the status bar like iOS 7 does.
What you can do is adapt the size so it does not lose any structure in your actual layout
First you can define a constant to know when it is iOS 7 or not:
#define kIS_IOS_7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
then in your AppDelegate you can change the navigation bar appearence like this:
UIView *background = [[UIView alloc] init];
if (kIS_IOS_7) {
background.frame = CGRectMake(0, 0, 360, 64);
} else {
background.frame = CGRectMake(0, 0, 360, 44);
}
background.backgroundColor = [UIColor blackColor]; // choose your color or image
UIGraphicsBeginImageContext(background.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[background.layer renderInContext:context];
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];

Resources