Showing posts with label Swift for iOS. Show all posts
Showing posts with label Swift for iOS. Show all posts

Tuesday, April 28, 2015

Adding a no animation segue to iOS

If you want a view to just appear without any animation or transition in iOS then this quick tip for you. First off you do not have to code a custom segue like is suggested on several sites. All that is required is selecting the correct preset segue type and changing a simple setting. Selecting Present Modally and unchecking the Animates checkbox. That all that is needed to have the new view just appear without any animation or transition. That much easier than writing a custom segue.

If you need to see how to do this then watch this short little video;



Thanks and happy coding :)

Saturday, April 25, 2015

iOS Xcode Auto layout device preview

When layout of a unversial app in Xcode for iOS, there a way to preview the unverisal layout on all apple device sizes within Xcode at the same time.

I been working with Xcode Swift with several companies and pretty much all of them never knew this could be done. It is a great little tip and I felt it is worth sharing with the world.




Enjoy and happy coding ;)

Saturday, February 28, 2015

Fun with Swift recap

Since 2015 we added a number of Swift tutorials to this blog for Mac OS X and iOS. I mostly have focused on Mac because I discovered there not many code examples around the web for Mac and swift. iOS there thousands of them and many are very good.

I also have been making apps for the Mac since 1997 and would like to see so many more jump on board to the Mac OS platform. Users are actually willing to pay money for a Mac apps, unlike iOS where anything over $0.99 is frowned upon.

I going to recap  back to all of the 2015 post we made so far up to March 1st on Swift.

Saturday, January 17, 2015

Using Swift for Mac OS X apps


The basic intro of using strings.

view topic

Tuesday, January 20, 2015

Hello Mac From Swift


A video walk through of Xcode and how to make outlets and actions. How to setup UI Controls, Windows with layout constrains. How to use and combine text strings.

view topic

Friday, January 23, 2015

Make OS X Web Browser with Swift


A video showing how to make a basic web browser with swift, inculding adding Google search.

view topic

 Saturday, January 24, 2015

 Sliders with Swift


A basic look at how to uses the a slider control.

view topic

Tuesday, January 27, 2015

Alert Messages with Swift


A look at how to present a NSAlert

view topic

Saturday, February 14, 2015

Alerts with Swift for iOS


A look at how to use alerts with iOS.

view topic

Wednesday, February 18, 2015

64-bit requirement for iOS


Simple info about all app store apps require 64-bit support.

view topic

Wednesday, February 18, 2015

Tabbar for iOS with Swift


A video to show how to add more tabs to a iOS tab view app.

view topic

Friday, February 20, 2015

Swift language update


Info about Apple beta release of Swift version 1.2

view topic

Saturday, February 21, 2015

Xcode swift tip: Access to docs fast


A tip on how to access header files fast in Xcode to quickly speed up development.

view topic

Monday, February 23, 2015

Swift for Mac Cocoa: Radio Buttons


A video show how to program with Radio Buttons and NSMatrix with Swift.

view topic

Wednesday, February 25, 2015

Swift for Mac: Programming Image Views


Another video showing how to load bundle images and present them on screen.

view topic

Thursday, February 26, 2015

Swift for cocoa importing files with open panel


Another video showing how to use a open panel to import and read files selected by the user.

view topic 

See All Swift Posts

View



I will be adding more swift examples this year, however I will also be focusing back on cross platform also.

Thanks and happy coding ;)

Saturday, February 21, 2015

Xcode swift tip: Access to docs fast

I discovered a faster way to access docs for a certain item already in your code. For those who may not be aware of this tip I like to share it with you, because I think you may like it.

Say you want to know what available to use for UIViewController. my simply command clicking on that text in the code editor will bring up the header file for the selected item. This making it super fast to find what you could use.

The Example below shows the UIViewController with a command click.

This will make the header for this class appear in the edit view.


This makes finding info to what you need to use extremely fast and helpful. I find it better than searching the help Api docs as it returns everything for the selected item.

Thanks, and happy coding ;)

Friday, February 20, 2015

Swift language update

Apple recently announced the Swift  language will soon be entering version 1.2 and with that it will bring several notable changes.

All of the examples I shown part of this blog up to now use Swift v 1.1,  Note I will continued to show Swift version 1.1 until Apple officially releases this new Swift version as GM public release. I am not able to show pre-released , based on my license with Apple.

Currently Swift Version 1.2 is in beta and can be used with Xcode beta 6.3. (this if you have an active Mac and or iOS developer license). You can learn more about it at Apple Swift Blog. Also note there said to be a migration tool that will be able to convert your swift version 1.1 code bases to version 1.2, which should be a major plus.

If your interested in swift I highly suggest you follow Apple swift blog for the new language changes and tips. Swift Blog Here You also can follow the blog va Twitter @SwiftLang



Wednesday, February 18, 2015

Tabbar for iOS with Swift

Working with Xcode and Swift is really simple. I keep getting amazed how fast and simple it is to use.

I keep getting people telling me that Swift and Xcode is hard. Also have some say it is s not as fast as Xojo or Livecode for iOS or Mac OS. Actually for iOS and Mac OS its just as fast if not faster. It is really not that hard once you grasp the basics of Swift and learn the ins and outs of Xcode. 



Today we look at using  Xcode and Swift for a iOS interface, Tab bar views. Xcode comes with a template with two such tabs. My video will go over what you need to do to add more tabs to your tab view controller. Its under 5 minutes long. So enjoy.

Video:



Thanks for watching, Happy Coding.



Saturday, February 14, 2015

Alerts with Swift for iOS

A few weeks ago I went over alerts with swift for Mac OS X. Well just to show how different alerts are between Mac OS X and iOS well take a look at several different type of alerts that can be used with iOS with swift.


First is the most basic alert that includes a title, message and up to 3 action buttons.



below is the code to set up the alert, and call it when a user taps on the button; btnShowAlert

//button action:
@IBAction func btnShowAlert(sender: AnyObject) {
      
       // set up the alert view
        let alertController = UIAlertController(title: "Hello World", message: "this is the obleo's alert message", preferredStyle: UIAlertControllerStyle.Alert)
       
       //set up the action button
        alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
       
        // show a alert view
        self.presentViewController(alertController, animated: true, completion: nil)
    }




That a little different to what we did with Mac OS X and swift. It has more code (however if you have auto complete on, most of its filled in for you.)

Another type alert that I use often is the alert with a text field. It has all the same options as above but includes a text field on the alert. ( you can have several fields if wanted, my example below screen shot show just one.)




To set up the alert with the field is not much different than the normal alert. There is just two added lines of code needed different than an normal alert. 1) add the field to the alert with addTextFieldWithConfigurationHandler and 2) setting up way to get the text added to the text field.

see code below:

//button action:
@IBAction func btnShowAskAlert(sender: AnyObject) {
        
// set up alert view
        let alertTextController = UIAlertController(title: "Your Name", message: "Name:", preferredStyle: UIAlertControllerStyle.Alert)
       
        // add the field to the alert (new)
        alertTextController.addTextFieldWithConfigurationHandler ({ (mainTextfld) -> Void in mainTextfld.text = "Add Your name"; })
       
        //add a button action
        alertTextController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (action) -> Void in
           
            // add code to preform action from user tapping OK button (new)
            let mainTextfld = alertTextController.textFields![0] as UITextField
            // present result on screen in UIText
            self.fldResult.text = mainTextfld.text
        }))
       
        // present the alert with field on screen
        self.presentViewController(alertTextController, animated: true, completion: nil)
       
        }

That it, swift is just amazing no mater if your targeting Mac or iOS. I noticing that swift for Mac is actually easier than iOS and is less lines of code than iOS for many of the same type of things.

Happy Coding ;)
 
PS I know its been a few weeks since I made a video, my old MBP finally died. I ran into issue with screenflow 3 is not working with my new Mac, I need to update screenflow to version 5+ and do not have the  extra cash today to make it happen. ( And yes I tried quicktime, but it not as professional as screenflow)