How should I approach building this 'my messages' mockup - swift [closed] - swift

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
apologies still relatively new to programming/swift. I've created a concept for a messaging app that has sliding buttons to filter/scroll messages but I can't work out the best way to achieve this functionality, so after some guidance on the best way to approach this.
I've considered:
Hacking a tab bar so it sits along the top (to switch between sent/received views etc)
Using a horizontal scroll view (not sure how to jump between the views using a button)
Using buttons to show and remove views programatically
I'm thinking of showing the individual message tiles using a collection view rather than a table view.
I'm also wondering if the design I've came up with is actually completely wrong as I can't seem to find any UI elements that behave in the way I expected (like the slider switches on my mock) and if I should completely rethink the layout. I'm open to that option if that's the case.
Any help/suggestions welcome!

You're asking a lot of questions - your post should focus on one task. Review How to Ask
But, to give you a couple ideas...
Take a look at UISegmentedControl. Here's an example only slightly customized:
A little searching will show you how to do that, or how to customize it even more (making the round-ends appear more like your mockup).
Below those, you could put two table views in a horizontal UIStackView. When you select a "Received / Sent" segment, animate the stack view to show the corresponding table view.
When you select a segment on the lower control, filter your data and reload the table view.
What you want to do, though, is just get started on it.
Begin with learning about UISegmentedControl and how to customize the appearance.
Then work on putting two views side-by-side and learn about animating their positions.
Then work on filtering your data source.
At each step along the way, if you run into a specific problem/question, come back and make a new post about that issue.

Related

How to Build Questions and Answer in Unity

Currently, I have no idea what is the best approach to sending information from one button to another in Unity.
For example, if you select tripping, it may have 2 questions and answers, while Tripping Flow Check may have 3 questions and 3 answers. Tripping Shut-In may only have 1 question and 1 answer but the answer could be a jpg file, etc.
The image at the bottom is the current setup but don't know how to set it programmatically in Unity. Any recommendation?
If you want to do it programmatically you need to create a script where you reference different UI elements and change them when you want and as you want.
You can communicate easily between your UI elements, gameObjects and scripts using Events. Thanks to Unity Events you can do it from the inspector.
For instance this way you can disable/enable another object with your button:
This way you can change the UI Text.text
You can call methods from your scripts exactly the same way. Simply drag the object you want to interact with to On Click() tab, find the script you want in the drop down menu and select the method you want to invoke.

Suggestions for a Crossword Board [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to iOS, although I have been with the basics and now I am trying developing a crossword app. Any suggestion where to start.
What problem I am facing the most, is to develop the 15 X 15 checkered board. I thought of two possible solutions -
To put 15 TextFields in each 15 rows, and according to the requirement I am going to disable the textfields and add black background color. But also there are two question, since the a crossword box has a number to the upper left corner, how can I put it? And the second is is it going to affect my performance since there are so many text fields.
Another possible solution I have thought of is coding a the board with CGRect and CGContextAddRect to the specified positions. But I am having problem on how to interact with the CGRect, that is when clicked it will bring up the key board and user can type the letter.
Please help, I don't know to where to start from. Other solutions are also acceptable.
I would suggest a UICollectionView. This is similar to a UITableView but with multiple rows and columns. Each UICollectionViewCell should consist of a UITextField.
For the numbers, you could either do that statically, i. e. you do it in your story board (place a UITextField for each number, the remaining space will be the UICollectionView.
Or (what I would prefer, but requires more logic) you make a 16x16 board and the 0th section and every 0th row in a section will be used for the numbers, the rest is for the actual crossword.
A best way is to use UICollectionView is you are targeting for iOS6+ or AQGridView if targeting older versions. Every cell is eventually a UIVIew.
Having custom textfield might make things complicated. Use UIKeyboard and set delegate as your collection view. In didselectrowAtIndex show your keyboard. Any keyboard delegate will return you character which you can set to Label at that box
There are few advantages for this over textfield approach
1) You can easily customize UIView/UILabel as compared to UITextField.
2) Labels can have custom fonts and attributed strings .
3) It's difficult to hide cursor in UITextField. which shows an editing mode.
Cons: Need Keyboard settings for Label. (However you can overcome with alternative controls like pickerview)
Also, make sure that you don't store any values in your views. Always refresh view from your data-structure (A 2-d array of characters).
Just a grid of views with labels in them should work. You might think its a good idea to be able to enter each character in place but it isn't. The user will have t tap Ana square type, type on another square, type...
So if you use labels you can have a different UI that let's the user enter a string in now go and then you can put the characters int the correct labels.

Customising iPhone App Interface [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am building a basic app interface which will have a mixture of text, inputfields and buttons. In order to get a working version for project deadline, I thought I would use the default Interface Builder (IB) components for the first iterations and then if there is suffiecient time, I would like to 'jazz up' the interface by adding customised components..
How easy is it to swap over IB components with customised ones at a later stage?
It depends on what you mean exactly by swap over IB components, but in general I would say that IB has full support for customization of your UI within its own conceptual framework. On the other hand, it is pretty obvious that defining your UI programmatically will give you all the customization possibilities you might think of.
In a sense, you can see IB as a way to declare graphically the elements of your UI, their relationships, and have them automatically instantiated for you when the IB xib file is loaded. This is a very flexible mechanism in itself and allows you plenty of possibilities.
Say, for example, that you have a button somewhere in your IB view. In a first release, you could set the class of that button to a plain UIButton; later, you simply specify that that button class is actually a YourCustomClass and you have it, your UI will use your custom button without you having to change much of code (maybe one line or two apart from the custom button implementation). The same holds true for many other kinds of UI elements.
Besides that case, there are classes, like UITableView, that I think are better customizable outside of IB (i.e., by specifying the customization, e.g., the custom cell, programmatically). But still in this case, having the interface defined in IB in the first place is not a big hindrance either, and you simply add the code that you need to your program.
Anyway, there are some customization that are not easily possible with IB. One example could be having more control on how and when your UI components are allocated; so, say, you are restricted to your xib file to be instantiated all at once, while programmatically you could trick every aspect of that. Or, there might be UI elements that are intrisically better suited for a programmatically definition (say, a scrollable grid of pictures), so IB would not fit the bill, or give little support for that (but you would not be able to define that UI elements with it in the first place).

How can I add a badge to a standard UIButton? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is it possible to add a standard-looking badge to a standard UIButton?
If it's not supported semi-natively, what would be the simplest way to achieve this?
Example image:
Here's a VERY NICE class by Sascha Paulus called CustomBadge, that builds and renders custom badges using Core Graphics. They're just UIView subclasses, so you lay them out using their frame just like any other UIView subclass.
I've used this library many times and always been pleased with the results. Flexible, easy to use. Totally recommend it.
You can check for several options here: CocoaControls Badges
The class that Apple uses is _UIBadgeView (https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/_UIBadgeView.h), but of course, this class is private (note the underscore) and not documented.
Here's another class that implements this view with the same look and feel as Apple's while also allowing you to customize it: https://github.com/JaviSoto/JSBadgeView. The great thing about this one is that it lets you position the badge relative to another view automatically, in one of its corners.
We have a badge view in Nimbus that's super easy to use and well documented:
NimbusBadge
I don't know how this is done out of the box and I honestly doubt that Apple built that into the SDK.
Anyway, you could create a custom view with a button on it, add the background of the badge as a UIImageView and place a label on it to hold the badge count.
That's a quick solution, it might be better to create a custom subclass of UIButton and add your badge stuff as a subview
I'd go a similar way as #Björn Kaiser: Use the button as you like it, and then add a custom view with that badge as a subview to it - I've done it and it works well.
As for the view, you can draw it as you like. You can draw it manually or use CoreAnimation and let it make the main part, i.e. theBadge.layer.cornerRadius = ...; to give it a round shape, draw the text/number in drawRect: or add it as a label etc.

iPhone User Interface Design [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I've just had a nagging question for a while regarding iPhone app user interfaces. For example, consider WeightBot's User Interface. I am wondering, how are most of these user interfaces created? In general, of course.
Is there a way to simply design controls (that is, the images) in a program like Photoshop, then use that 'skin' for controls in UIKit? I realize that there are some controls that are probably created by the programmer (custom controls), but I'm referring to the ready-made ones that come in UIKit.
In other words, is the concept similar to 'splicing' web site designs? Where a designer draws out the design of the website in something like Photoshop, and then it is cut up into pieces which can be applied to form the actual website? I know this can be done for UIButtons, can this also be done for other controls, and is this how it is usually done?
Or perhaps this is done with Core Animation? I've heard this from time to time, so does this mean that the User Interfaces are 'hard-coded'? Or is Core Animation only used for the 'effects', such as applying the glowing effect to the numbers in WeightBot?
If there are any resources you can point me to I would really appreciate it.
I've asked myself the same question and just like you i couldn't find any examples. After playing around i've managed to create a similar control. You can check it out on github http://github.com/kompozer/HorizontalSliderControl
Its very simplistic but i hope you get an idea. Basically its a UIScrollView, not much core animation needed.
I can't think of any written resource about this practice. But you are on the right track about Photoshop. Designers create assets visuals for the different controls in some design app such as Photoshop. Developer then assigns these assets to controls, e.g different states of a button are loaded as images, and maybe text added in code.
Looking at WeightBot UI and the big blue glowing numbers, I can think of two ways doing them:
1) precreate all the digits 0-9 in photoshop, and put them together at runtime (just load UIImageViews into UIView, calculating the sizes and positions at runtime)
2) create the text with something like UILabel and then apply effects to it programmatically at runtime.
Both ways are fine and both have different tradeoffs about app size, code maintenance, developer/designer skill required, performance etc. It is also common to mix these all over the place, especially with something like a fancy background image + text created at runtime on top of it.
You are correct that all of this is quite similar to web slicing and requires you to think about what elementary pieces the interface consists of and how to composit them together.