Images of UITableView Cells change? - objective-c

While i finished developing an in-app-purchase application, and after several testing on iPad/Iphone, every thing was fine, the images of table view's cells and its hight was exactly as wrote in code, so i upload the application, when it was processed to the app Store, i download it, the table view cells in both IPhone/IPad were in different sizes much bigger size then that was set while testing,so the image in cells was like stretched!!!!and not clear, i tried to test it then directly via xcode to my device, it was almost fine as before, but the problem is only when downloading from store,
I really appreciate any help,
Regards,

This is quite likely to be do with floating-point calculation optimization.
When building for release, by default, Xcode will try to fully optimize your code, including making your floating-point calculations more efficient. However, sometimes they can be incorrectly optimized, and this can cause major issues especially with positioning / sizing of views etc.
For me, this happens when building for release + armv6 architecture, and I've had exactly the same problem (only realized when released) before.
Thankfully, there is a way to disable the floating-point optimizations. Here's how:
Using LLVM GCC 4.2
Click on your project in the files pane on the left
Click the project name under Targets (as seen below), then click "Build Settings".
Search for "thumb" in the search box on the right hand side
You should see a setting called "Compile for Thumb" under "LLVM GCC 4.2 - Code Generation". If you don't, it's because you're using the Apple LLVM compiler 3.0 (instructions for that are below).
Hover over Release, and click the plus icon.
A new option should appear, with a drop-down, select "ARMv6" from the dropdown.
Then select "No" for that option. It should now look like below:
Using Apple LLVM 3.0 Compiler
Follow steps 1 and 2 above.
Search for "other c flags" in the search box
Follow the same steps above to add a specific configuration for ARMv6 + release.
Double-click the box with the flags in, and add the flag -mno-thumb. It should now look like below
If it still has issues under the release build after that, you may want to try disabling compile for thumb globally.
Hope that helps.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 120; // also custom uitableviewcell should have same height
}

Related

Why does Xcode autocomplete always put my custom code snippets above actual completions?

I am using some personal Xcode snippets for shortcuts for like dispatching on main queue, or a #synchronized code. They have never interfered with Xcode's autocomplete function with regular methods.
Some time ago I've formatted my Mac, installed Xcode, and re-created the shortcuts the same way I did before:
Ever since, my shortcuts are always before anything else when autocompleting methods containing spaces, as seen below:
The completion for methods should obviously come before my custom snippets.
It also occurs before anything else on property completions either:
They should get listed and highlighted as I type d or dm, or s, sy and so on, just like the default snippets. They shouldn't be at top of everything.
Why would have it changed after the format, and how do I correct this (mis)behavior?
(I am currently on Xcode 9.3 but the problem used to occur before 9.3 too)
UPDATE: The issue still persists on Xcode 9.4.
UPDATE 2: The issue still persists on Xcode 10.1.
Well, there is a new update Xcode 9.4, try with the update because I had the same problem, my solution was delete Xcode and reinstall the latest version, but I think only you need to clear the configuration to return like a first launch.
In the release note for Xcode 9.3 says:
Text in the Code Snippets library filter bar now includes code completion shortcuts. (8147546)
User-defined code snippets now appear at the top of the library, rather than the bottom. (8901028)
You can read full changes here Xcode Releases Notes

Thought I successfully added Cocos2D to my Cocoa Touch project, but autocomplete shows no CC classes

Following several online tutorials, I managed to get Cocos2D added to my Cocoa Touch (UIKit) project. Problem is, I'm able to #import "cocos2d.h" at the top of any one of my files and my game compiles and runs fine, working just as it did before, but I don't have access to any of the cocos classes, like CCNode, CCLayer, etc.
To give you an idea of what the app does, currently, the main menu UITableView comes up, scrolls as it should, buttons that lead to various view controllers (facebook, twitter, new game creation, store, settings, etc.) all work fine. Back buttons in each view return the user to the main menu table view. This is pretty much all it does, as of now. The idea at this point would be to pass the baton to a Cocos2D scene--where the gameplay would be--when the user taps on one of the UITableViewCell's that represents a current match.
The process I used to add Cocos2D to my project was this:
Drag and drop the cocos2d-ios.xcodeproj into my "supporting files" folder
Under "Link Binary with Libraries" heading under "Build Settings" for my project, I added libcocos2d.a (which continues to show up red, even after "successfully" adding Cocos2D), libz.dylib, OpenGLES.framework, and QuartzCore.framework. They all read "required."
Under "Build Settings" for my target, set "User Header Search Paths" to "/Users/Home/Downloads/cocos2d-iphone-master-v2/**" (recursive), which is where my Cocos2D library folder is.
Under "Build Settings" for my target, set "Always Search User Paths" to YES.
Did the same two steps identically for my project's "Build Settings"
Went through and selected all the Cocos2D .h and .m files and set -fno-objc-arc compiler flags for all Cocos2D files, which enables the pre-ARC calls to retain, release, dealloc, etc. in the old Cocos2D files to play nice with all the post-ARC files in my project.
Also worth noting, perhaps, is that when I create a new file in my existing project "cmd + n", the only options available to me under Cocos2D templates is the CCNode class.
Am I missing something, here? Again, to be clear, I can import the cocos2d.h file and it looks as though everything will work fine. But, when I try to define anything that starts with a "CC", autocomplete shows nothing. Any help would be appreciated. Beating my head against the wall, here. TIA
The autocomplete issue is most likely because of the recursive search path. Xcode has problems indexing recursive header search paths (especially if you just drop in a .xcodeproj). Change it to an absolute path, add multiple paths if the source files are spread across multiple folders.
With Xcode 4 you shouldn't drop in a xcodeproj to another project anymore. Use a workspace to combine multiple projects side-by-side in a single workspace. See Kobold2D for an example (or just use it if you continue to have problems, because these things are already solved in Kobold2D).

Xcode 4.4 - Unable to add compiler flags to compile sources

In Xcode 4.4 it seems I am unable to add compiler flags to individual source files. I am trying to remove ARC from a single file but I can not get the pop up to add flags. Double clicking or selecting the item and pressing enter does not work, also tried selecting multiple and pushing enter which does not work. I have tried with two separate projects, one of which I created with Xcode 4.4. Is there another way to manually add compiler flags to a source file? (I do not have an older version of Xcode to see how it stores the value [likely in the pbxproj]).
Note: MacBook Pro w/ Retina Display - OSX 10.8
I found where the window was hiding. I had to drag Xcode pretty far down to the lower left corner of my screen as the pop up window was showing up and to the right. This made it completely hidden while full screen.
A bug report has been filed rdar://11970271

Code loses syntax color in Xcode 4

I have just upgraded to the new Xcode 4 and the code is not colored has it ought to be.
For instance, the string NSString is not colored in my custom code, but when I switch to Apple's code (NSString.h for example) everything is well colored.
How can I fix that?
It's a known bug with the latest XCode. This happens with some projects which are migrated from XCode 3.X to the new version. For some people it seems to help to go to the organizer, and in the project tab delete the derived data for the project where code sense does not work correctly.
If you have a small project, it might also help to create a new project in XCode 4 and import the files from the XCode 3 project.
Update: XCode 4.0.1 made the situation a bit better, at least in some of my projects I have syntax coloring and code sense back. But it's still far from fixed.
Update 2: XCode 4.0.2 did not change much. It seems that the problem is related to subprojects, specifically static libraries. According to comments of this blog post some people were successful by changing header search paths from relative to absolute paths, e.g. instead of Foo/Bar use $(SOURCE_ROOT)/Foo/Bar. This together with switching all projects to XCode 3.1 format and to use LLVM 2.0 fixed a lot for me as well. It's not perfect yet, but usable.
Update 3: After converting the sub projects to independent projects and putting them in a workspace (aka the XCode 4 way) I have now full syntax highlighting and code completion back.
My current environment is now a XCode 4 workspace with each projects being 3.1 compatible (as opposed to the default which is 3.2), LLVM GCC 4.2 (system default) and the header search paths are still absolute (using $(SOURCE_ROOT)/.../).
I used undefined Macro, But those macros defined in Preprocessor Macros in build settings. So the xcode4 didn't generate any error for that undefined macro.
Steps taken to resolve.
Removed undefined macros wherever I used those undefined macros.
Removed duplicate definitions of Marcos.
Removed duplicate Resources. (I'd added same (many Thumbs.db files) files into the project.)
Clean & Build.
if still you are not getting the color then, please relocate your project to some different location, I changed to my Desktop location.
After these steps I got the color in my eyes.
But its very bad issue. I sucks lot of valuable time. I think these steps may help you.
Thanks.
I had the same problem with mine. Its a cocos2d game with box and chipmunk. It was a hell of a mess getting the project to recognize and find the user search paths in the first place so I wasn't about to mess with those.
What I wanted to point out is that I DO HAVE recursive paths and I do have relative paths and I still got the issue. It happened when I added a new version of a 3rd party SDK I was using. It was Testflight 083 which I updagraded to 1.0. I erased my old version but only removed references. Then I manually deleted it from finder. Imported the new SDKv1 folder and readded it to my project and removed the old SDK0 folder path leaving only the newly added SDK1 folder path. For some reason I noticed that even though in v083 I had used a #import in my Prefix.pch file, it still wasn't recognizing a call to a method from AppDelegate. Which means the #import in Prefix.pch for some reason was not working. I had to add #import to my AppDelegate file individually. This gave me duplicate #imports as Jeeva said above. That sounded an alarm in my head.
So the solution was to go and effectively remove the duplicate #import in Prefix.pch therefore only leaving the one in AppDelegate. It reindexed and CodeSense works again. Thanks Jeeva!
This issue was driving me insane, and I had given up hope of fixing it without some ugly hack on XCode's configuration. I passed through this very forum thread a stack overflow of times. Then one day, I happened to accidentally fix it. I'm not sure if you need all these steps, but I've found this a sure-fire way to fix XCode's indexing issues:
Clean your project (Command-shift-K)
Open organizer, close your project.
Under the "Projects" tab in organizer, remove the derived data for the project you want to reset.
Quit XCode
In the terminal, run:
sudo mdutil -a -i on
This seems to reset spotlight indexing (I don't know much about it because I don't use spotlight).
When the command finishes, Spotlight will have to re-index. Look up to see a little dot in the magnifying glass for your spotlight's icon. When the dot leaves, spotlight has re-indexed. You can check the progress by opening spotlight.
Re-open XCode, and wait for it to re-index all your files.
Build the project.
On build success, you should now have appropriate syntax highlighting again. I hope you guys find this little discovery as useful as I did :)
EDIT:
I should probably add that the syntax highlighting sometimes seems to re-break when the debugger hangs the simulator during app launch. I just try to avoid this by being more careful about letting the process hang.
EDIT2: (sorry first contribution)
Works on XCode 4.6 and 4.6.2.

XCode Syntax Coloring Broken

XCode frequently seems to lose it's mind, and doesn't color code system classes or provide correct "code sense" suggestions. This is endlessly frustrating. The question has been asked on at least three other occasions:
Problems with Xcode Syntax Highlighting
xcode code sense color/completion not working
Xcode: code loses syntax coloring
I have switched by project version to/from 3.1-compatiable and 3.2-compatiable, completely restarting XCode before and after each change with no effect.
I have rebuilt the code sense indexes and completely restarted XCode with no change.
I have built my project to make sure there are no errors and restarted.
I have copied my files (sans .svn files) to a different location - same problem.
I've already completely disabled the argument "placeholders" because they screw up my documents when i type too fast... all I'm asking for is for the "esc" key to display the correct list of properties and methods.
You should clean your project's derived data. They are likely corrupted.
Go to Organizer > Projects > Your_Project > Derived Data > Delete
Xcode will reindex your project and you should be back to normal.
For anyone interested; my app has some precompile directives:
#if ...
Turns out there was an error in one of these sections.
I'm assuming my app built fine because these sections were stripped out before they ever got to the compiler... but CodeSense doesn't care about these (it still wants to color code everything inside these) - so CodeSense would puke all over the place because of the error, even though I didn't find it when I tried to build the app.
Once I fixed the error within that block of code, my coloring returned.
Would be nice if XCode just greyed out those sections instead of dying.