15. Black Launch Screen / Images vs iOS 7 / iOS 8 and XCode 7

Hey Guys, if you have landed here while searching about ‘black screen’ or ‘no splash screen’ or ‘black launch screen’ on iOS 8 or 7 devices using XCode 7, then its the right place for you because somehow I figured out the working solution for it.

1. First step is to make Launch Screen.storyboard, which seems to be compulsory to make it work on iOS 7 and iOS 8.
2. Go to XCode->File->New->File->User Interface->Launch Screen

Screen Shot 2016-06-19 at 4.23.39 pm

3. Inside the View, remove existing default labels and add image view with your launch image, also make it ‘aspect fit’ mode.

4. Create constraints for image view by XCode->Editor->Resolve Auto Layout Issues->Reset to suggested constraints, so it should look like below.

Screen Shot 2016-06-19 at 4.25.13 pm

It is required to auto resize of imageview for different device’s screen size.

5. Now Go to XCode->Project Settings of Target->General, and set Launch Screen File as your newly created storyboard file name, in my case its LaunchScreen

Screen Shot 2016-06-19 at 4.29.56 pm

6. We also have to set Launch Image set by clicking on ‘Launch Images Sources’ and then add iOS Launch images in xcassets file, as shown below

Screen Shot 2016-06-19 at 4.33.21 pm

7. Also make sure you unselect ‘iOS 7 and later’ options, just add images for ‘iOS 8 and later’ and ‘iOS 6 and later’ options, as shown below

Screen Shot 2016-06-19 at 4.36.08 pm

8. Now select ‘LaunchImage’ option at ‘Project settings of target->General->Launch Image Sources’.

After doing above 8 steps, your issue of black screen should be resolved, in case if you still find problem, please do comment here with details and I’ll try to get back asap.

14. Add Album Art to mp3 files in iOS

Prerequisite: Download ID3 C Library from here – http://sourceforge.net/projects/id3lib/files/id3lib/3.8.3/id3lib-3.8.3.zip/download

And use below method to add album art in the given mp3 file:

-#import <id3/tag.h>//update the Header Search path with the location of this library under your project

-(void)addMetaDataToMP3File:(NSString*)songFilePath withAlbumArtFile:(NSString*)artworkImgPath

{

    

    ID3_Tag tag;

    tag.Link([songFilePath UTF8String]);

    tag.Strip(ID3TT_ALL);

    tag.Clear();

    ID3_Frame frame;

    frame.SetID(ID3FID_PICTURE);

    frame.GetField(ID3FN_MIMETYPE)->Set((constchar *)[@"image/jpeg"cStringUsingEncoding:NSUTF8StringEncoding]);

    frame.GetField(ID3FN_PICTURETYPE)->Set(ID3PT_COVERFRONT);

    frame.GetField(ID3FN_DATA)->FromFile((constchar *)[artworkImgPath cStringUsingEncoding:NSUTF8StringEncoding]);

    tag.AddFrame(frame);

    tag.SetPadding(false);

    tag.SetUnsync(false);

    tag.Update(ID3TT_ID3V2);

}

 

13. ‘Library Search Path’ checkpoint !

We usually include 3rd party library files (.a) by drag and drop or by Adding new file in Xcode Document directory window,  when they are moved to new folders when we update to latest library files, we normally delete the old one and add the new one.

There is one glitch here i.e. Xcode’s ‘Library Search Path’ setting under Target’s build setting still points to old location, which leads to wrong product. Since it will take the library folder (.a) file from old location only even though you have added new library file (.a) in your project.

To fix this issue, just remove the old location from ‘Library Search Path’ and you are good to go…

12. UITableview scroll to bottom on reload?

Try this:

NSIndexPath* ipath = [NSIndexPath indexPathForRow: cells_count-1 inSection: sections_count-1];
[tableView scrollToRowAtIndexPath: ipath atScrollPosition: UITableViewScrollPositionTop animated: YES];

original post: http://stackoverflow.com/questions/5112346/uitableview-scroll-to-bottom-on-reload

11. When Xcode fails to open Organizer after successful Archive

Try adding “/Application” in “Installation Directory” under build setting of target app for the same configuration used in Archiving.

 

 

10. Two fingers gesture on UIScrollView

Most of the times we want to do something different in iOS apps, one of them is two go for 2 finger scroll instead of 1, so that we can have some other control like UITextView in 1 finger scroll. So here is the code to have this:

for (UIGestureRecognizer *gestureObj in self.detailContainerScrollView.gestureRecognizers) {
if ([gestureObj isKindOfClass:[UIPanGestureRecognizer class]])
{
UIPanGestureRecognizer *panObj = (UIPanGestureRecognizer *) gestureObj;
panObj.minimumNumberOfTouches = 2;
panObj.maximumNumberOfTouches = 2;
}
}

9. iPod touch / iPhone 1st gen, 2nd gen and Xcode 4

Ever since Xcode 4 has come out, many people are having trouble running their apps on older version of iOS devices. With few manipulations here and there in XCode and in device, you can definitely find a work around… Here are my findings..

1. Try to rename the scheme at XCode 4, you can do this as follows:
Go to Xcode->Product->Manage Scheme. Then click on the setting icon at the bottom of popup, select Duplicate. Delete the older one. Restart Xcode and also reconnect device.

2. In Build Setting of Project and Target, make sure your Architecture is armv6 $(ARCHS_STANDARD_32_BIT) or armv6 armv7.

3. In -Info.plist file, find “Required device capabilities” and delete “armv7”.

4. Try resetting the device’s Date and time to current date and time, even if it is already set to current. Go to Settings->General->Date And Time.

Hope any of the above steps may help you to beat this annoying and time killing bug…

8. Its Official : GoDaddy server not connecting to external SMTPs

I have been trying to write a php script which can email using smtp may be Google account or any other account, but after spending lot of time, I found that Godaddy (where I have my hosting account) doesn’t even allow scripts to make socket connection. Embarrassing, isn’t it !

Have a look into this link : http://community.godaddy.com/groups/web-hosting/forum/topic/godaddy-server-not-connecting-to-external-smtps/

7. Show Arabic text on UILabel, UITextView, etc.

I got stuck for this requirement when I was getting response from server in two languages, English and Arabic, for English it was giving normal text but for Arabic, it was returning text something like this…

&#1606;&#1585;&#1610;&#1583; &#1571;&#1606; &#1606;&#1585;&#1609; &#1607;&#1584;&#1575; &#1601;&#1610; &#1575;&#1604;&#1604;&#1594;&#1577; &#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;

So then I figured out from ‘Stackoverflow.com’ that these are code for arabic font and we have convert it into respective font strip using proper encoding, which is as follows:

int c = ... /* your 4 text digit unicode ordinal converted to an integer */
charString = [ NSString stringWithFormat:@"%C", c ];
//originally posted by hotpaw2 at this link.

But its just one char what if you want to show full sentence so I have made a small utility which will take arabic codes as input and will return string containing arabic font, as follows:

-(NSString*)toArabic:(NSString*) arabicCode
{
 NSArray *wordsArray = [arabicCode componentsSeparatedByString:@" "];
 NSString *sentence = @"";
 for(int i=0;i<[wordsArray count];i++)
 {
 NSString *word = [wordsArray objectAtIndex:i];
 word = [word stringByReplacingOccurrencesOfString:@"&#" withString:@""];
 NSString *arabicForm = @"";
 NSArray *charArray = [word componentsSeparatedByString:@";"];
 for(int j=0;j<[charArray count];j++)
 {

 int code = [[charArray objectAtIndex:j] intValue];

 if(code!=0)
 arabicForm = [arabicForm stringByAppendingFormat:@"%C",code];

 }
 sentence = [sentence stringByAppendingFormat:@" %@",arabicForm];

 }
 //NSLog(@"%@",sentence);
 return sentence;

}

How will it work?


NSString *arabicString = [self toArabic:@"&#1606;&#1585;&#1610;&#1583; 
&#1571;&#1606; &#1606;&#1585;&#1609;   &#1607;&#1584;&#1575; 
&#1601;&#1610;   &#1575;&#1604;&#1604;&#1594;&#1577;   
&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;"];
NSLog(@"Arabic text:%@",arabicString);

Hope it can help you somewhere.

Let me know for any confusion....