Xcode 4 - Dynamic Interface Tutorial needed - xcode

I'm trying to create a news viewer with Xcode 4. This should look like the following:
===============================
Title comes here ------- Date
Image
News Body
================================
As you can see, the news body must be pushed downward depending on the size of the image. The image must be pushed downward as the height of the title varies. I know I have to do some programming to position them dynamically. The only problem is I'm not familiar with CGRect and Frame things...
Where can I find a tutorial or sample code I can take a look and get some ideas? Practical codes or tutorials would be appreciated as just reading documentation doesn't really give me a clear idea how to approach this.

UILabel provides -sizeWithFont:constrainedToSize:lineBreakMode: which will allow you to determine the size needed to fit the text you wish to display. I put together an example of resizing UILabels when I first ran into a similar problem and posted it here: http://blog.carbonfive.com/2009/07/10/resizing-uilabel-to-fit-text/
I'm afraid that's rather old now but I think should still be of some use.

Related

create a simple (and visible!) UI slider in Unity 5

![enter image description here][1]please I need some help, this should apparently be something very simple and basic to do, but maybe I'm missing something.
I'm quite newbie to Unity3d, I had no much problem with creating a somewhat flashy 2.D scene (I mean 2D with different layers in Z level), scripts, etc. But I'm having trouble to create a "UI Slider" object: when I create it, it just shows nothing on screen. How can I make it visible? I just need to create a very simple, plain slider whose value can be controlled at runtime by means of a script.
thanks.
Well.. since you give nothing to go on, I suggest that you take a look at a tutorial for the UI:
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/using-the-ui-tools
If you have troubles after this tutorial, come back with an example of your problem to make people more willing to sacrifice their time in helping you.
Hope this is somewhat useful
Take a look at the Unity3D docs here.
http://docs.unity3d.com/Manual/script-Slider.html
It should have what you are looking for.

Add an image to MKMapView (SWIFT)

I'm trying to add an image to MKMapView using SWIFT and I have ZERO coding experience. Could someone provide me with ALL the sample code necessary to do this? If there are any placeholder words (like overlay.yourimage.mapView) could you put the place where I need to add my information IN CAPS? I can't even tell the parts where I'm supposed to add my own information.
I appreciate any responses, I'm a first time poster.
Welcome to Stack Overflow.
The short answer is no.
This is not a site where people write your code for you. It's a site where you come when you have specific problems with code you've written and need help.
Be warned that MKMapView is a pretty complex framework. If you have zero programming experience it is way, way, WAAAAAAY over your head. You need to start with "Hello World" type stuff and work your way up.
Starting your programming career with trying to customize a map view is like going down a black diamond ski trail the first time you put skis on. You will fail dramatically, and won't be ready for black diamond trails (advanced APIs like map kit) until you do a lot of groundwork.
You can probably find sample code online that deals with adding an image to a map view, but it's not going to make much sense to you at this point, just like a ski instructor explaining how to get through a difficult mogul field won't make much sense to a beginning skier.

Placing images on top of other images in wxpython

I know this question is pretty basic, and I'm sorry for posting it, but I literally have spent the last hour googling and I still havent found an answer.
I coded a blackjack game using pygame, and want to convert it to wxpython mostly as a way to learn wxpython. In pygame the graphics are easy, I have a base image I display (basically just the table), and then I can just display other images on top of it as the action unfolds, for example the cards. Each time the player hits I just draw a new card in a different position. When The hand is over and I want to go to the next hand, I just display the base image again, and it covers everything up and viola! Its really simple all I have to use is blit() and pygame.display.update().
I cant seem to find anyway to do this in wxpython. All the examples I find are for drawing items in new widgets, or drawing vector graphics over an image, or opening new frames with images, etc.
any help is greatly appreciated, thank you very much.
--Daniel
The AlphaDrawing example in the wxPython demo shows how to overlap multiple drawings. This uses wx.GraphicContext / wx.GCDC. If you look at the documentation, you'll note that it has CreateBitmapFromImage and CreateBitmap methods that probably apply to what you want to do. See also the DragImage demo and the following links for related information:
wx python card game
http://rummy-py.sourceforge.net/ (look at the original that was done in wx)
I found this post, which reading the comments, does a good job of showing me want I was looking for.
Delete image in wxpython?

Zoomable image like google maps

I would like to create a website that has a large image of a tree from a distance on. When you zoom in it shows more defined image of the branches and then zooming in further the words will display in the braches. You can scroll the image to see all the other words. So its like google maps but for my own image.
I have tried looking for examples etc but can only find ones of maps. I believe I have to make different tiles for the different levels.
Is there any examples or tutorials out there that could help me or is there a specific name for what I should be looking for.
The easiest way to do it is to use a tool called MapTiler.
It's free, and you just follow a really simple wizard that just hides all the complexity from the process.
Anyway, I've posted a tutorial exactly on this topic which you can check here.
I created a Java based version of a Google Map Tiler tool here:
https://github.com/devldevelopment/googlemaptiler
This will help you cut up images as per Map Tiler but is free. An example with Javascript is provided on the github readme.
Thanks

Chat Bubble Cocoa

I have been trying to create a chat bubble for about a month now... (you know, like the one in iChat or Tweetie). At some point I found a thread that said that I could use Twitterfon's source... which I did. But I get stuck for a few reasons. Which ones? Apple didn't seem to implement all the methods needed for calculating the rect's size. E.g.: NSTextField doesn't implement a method that allows me to give an NSRect in order for it to calculate the best size. The fact is, Tweetie's bubble rects are always perfect. I dropped him a line asking how he did that, but I didn't get a reply. Although, I understand, because it is used in a commercial application. I thought that with the popularity of iPhone's SMS application (and iChat, or any app including chat bubbles), someone would probably made an implementation on OS X, and made it open source. I am not very experienced, and mainly I don't have time (school), so this is why I have been working on it for one month and have not found a solution.
If someone created the thing on Cocoa, would they please explain their solution for it ? Or even better, show some code...
The AppKit NSString Additions have methods to measure strings for drawing, and for more advanced purposes you can use NSLayoutManager. See the Text Layout Programming Guide for more info.
Alternatively you could use WebKit and HTML/CSS. I believe this is how Adium achieve their IM message themes.
Check out the BubbleThingie sample code for example of how to do the image masking. It also has example of how to do the text bubbles using a UIButton or UILabel and does all the size calculations. it also allows to tint the bubbles any color.

Resources