Post

Replies

Boosts

Views

Activity

Reply to How to assign constraints to a Scrollview which covers part of the screen only?
Claude,Ok, I created a brand new test project.1) I placed a Scrollview (with light blue background) into the default ViewController and set ScrollView constraints as follows: leading = 0 to safe area trailing = 0 to safe area top = 150 to safe area bottom = 150 to safe area2) I added a ContentView UIView (with yellow background) inside the ScrollView with the folliowing values and no constraints set at this time: X = 0 Y = 0 Width = 700 Height = 7003) I added many buttons and labels inside the ContentView which have been positioned down the left side of the ContentView in a vertical fashion from Y=0 to Y=600 so some of the buttons/labels go outside the display viewing area.4) Here is the code:import UIKit class ViewController: UIViewController { @IBOutlet weak var ScrollView: UIScrollView! @IBOutlet weak var ContentView: UIView! override func viewDidLoad() { super.viewDidLoad() ScrollView.delegate = self } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() print("viewDidLayoutSubviews") ScrollView.contentSize = ContentView.frame.size } } extension ViewController: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { print("scrolling is occurring. You can see the ScrollView scrollbars moving as well") } }4) In the size inspector for the ScrollView, I unchecked the "Content Layout Guides" option box.Results:In IB...- The constraints of the ScrollView are still RED and switching to landscape in IB does not resize the ScrollView dimensions- Still receive the "Scrollable content size is ambiguous for Scroll View" warningWhen running the application...- The ContentView contents CAN be scrolled up/down/left/right to see the full UIView (as previously)- Switching the landscape mode resizes the scrollview area (as previously)Issues which still remain as before:I cannot assign constraints to UIButtons/UILabels located within the ContentView since no ContentView constraints are set. Setting these constraints is the main goal of mine.When I set the following 4 constraints on the ContentView, then scrolling no longer works when running the application, although you can see scrolling events are being processed and also notice the scrollbars on the ScrollView are moving around as well. leading = 0 top = 0 width = 700 height = 700Questions for you1) You indicated you set ImageView constraints. What exact ImageView constraints did you set?2) Instead of using an ImageView, can you try a UIView and place UIButtons inside the UIView and see if you can set constraints on the buttons?
Jan ’20
Reply to How to assign constraints to a Scrollview which covers part of the screen only?
Hey Claude,Sorry for the late response. Just returned back into town.Unfortunately, I decided I spent way too much time trying to hack together a ScrollView to get it working. I resorted to plan (a) below: a) Never assign constraints to any objects located within the content UIView and update object positions via the code onlyI read through your websites and it is really going to take me some time to slowly read and re-read this material to understand what they are talking about. I bookmarked all of this material and if I ever have to deal with a ScrollView again I will re-read all of this stuff and try again. I just cannot afford to spend hours anymore on ScrollView work. Too much other stuff to tackle.
Jan ’20
Reply to How to assign constraints to a Scrollview which covers part of the screen only?
my code does not work. I have been trying for two days. I always dread trying to work with a ScrollView since I never can get it working.The simple issues are:1) Put ScrollView into ViewController and assign these 4 constraints --> leading/trailing safe area=0 and top/bottom safe area = 150ScrollView constraints remain REDIf you switch to Landscape mode then ScrollView dimensions do not change2) Put UIView into ScrollView with these dimensions --> x=0, y=0, width=500, height=500I cannot assign constraints to UIView since ScrollView constraints are not set3) Put UIButton into UIViewI cannot assign constraint to UIButton since UIView constraints are not setDue to these issues, when I use a ScrollView I eventually end up doing one of the following:a) Never assign constraints to any objects located within the content view UIView and update object positions via the code only. ORb) Position the objects in the content view UIView and ensure they do not have to change positions when switching between Portrait and Landscape modes. Basically, just allow the ScrollView to scroll through the same looking objects no matter what orientation I am in.It seems like I am going to need to choose (a) or (b) again and not really layout the objects via constraints like I want to. It just means I have to assign a name to eveery single object located in the UIView and then write more code to manually position them during an orientation change.
Dec ’19
Reply to How to send Invite to iPhone using IOS simulator
ok, I think I understand, but perhaps you can confirm?I have a real "iPhone1" connected to the Mac and the IOS simulator runs the application on this "real iPhone1". The "real iPhone1" can then go into the application and "Invite" the second "real iPhone2" user to play the game. I can see the debug information from "real iPhone1" on the simulator. I then reverse the test using iPhone2 to invite iPhone1 to see the invite request coming into iPhone using debug output.
Dec ’19
Reply to How to assign constraints to a Scrollview which covers part of the screen only?
>>May be have a look here: h ttp://synappse.co/blog/uiscrollview-has-ambiguous-scrollable-content-height/This webpage indicates setting the ScrollView and UIView to have constraints all set to "0", which will not work for me. This example shows how the UIView gets larger when more and more text is added to the TextField thus pushing the UIButton (and text) out of the visual screen area, thus allowing scrolling to be initiated. I am assuming when the ScrollView constraints are all set to "0" then they are all RED for this guy as well, but he never mentions this at all>>If you want to work on view larger that the viewController (for the content view), you can either:- do it by hand, selecting objects in the list and setting the position and constraint without viewing it inside the viewController- or use freeform for a while- or create a xib for the viewThis is not a problem. I simply reposition the content UIView, as required, within the viewController so I can see all objects which were previously off the screen. I can then assign constraints and positions as desired. This is not that bad as I am not dealing with ScrollViews that often. If I was constantly dealing with ScrollViews, then this technique would eventually get annoying.For testing, I created a brand new Xcode project and did the following:1) I added a ScrollView with the following constraints: leading safe area = 0 trailing safe area = 0 top to safe area = 150 bottom to safe area = 150There are RED lines around the scrollview and a warning which states the "content size is ambiguous"I tried adding fixed width(375) and height(367) constraints to the ScrollView to see if the RED lines would go away (based on your comment) but they did not. I then removed these width/height constraints since they did not help and really should not be required anyway. Are you saying you were able to get the RED cosntraint lines to turn to BLUE by adding width/height constraints somehow?At this point, if you switch to "Landscape" mode you will see the ScrollView object does not resize itself based on the assigned constraints, which is odd. I guess then means I cannot assume the ScrollView dimensions will be properly set when my application enters Landscape mode. (Note: To resolve this issue, perhaps we need to place the ScrollView inside of a BaseUIView object, whose constraints are set as desired, and then ensure the ScrollView frame size is always equal to the BaseUIView? :>)In the viewDidLoad() I have the following --> myScrollView.contentSize = myUIView.frame.sizeThe UIView is where I am planning on adding all of my buttons and labels which the user can scroll around and see.I do not want to set the UIView leading, trailing, top, bottom constraints to be 0 (like you did) since I do not want the UIView to be the same size as the ScrollView. I need the UIView dimensions to be larger than the ScrollView so scrolling will be allowed. I am going to use the Auto Layout "Vary for Traits" option to set different button/label/etc. constraints depending on whether I am in Portrait or Landscape modes so I need to be able to work with the complete UIView dimensions.Questions:a) Is there a way to resolve the ScrollView "content size is ambiguous" warning in interface builder to make all constraint lines turn BLUE?b) In the code, I make sure the UIView height/width are correct and also make sure the "ScrollView.contentsize" is set appropriately. In order to set valid (BLUE) constraints on the objects (buttons, labels, etc.) located within the UIVIew, I must first set valid (BLUE) constraints for the UIView itself first. As a result, I set the following constraints for the UIView: leading = 0 top = 0 width = 700 height = 700I then set valid (BLUE) constraints for all buttons, labels, etc. located within the UIView.When I run the application and attempt to scroll, I see the "scrollViewDidScroll( )" UIScrollViewDelegate function IS being called repeatedly, but no actual scrolling of the objects is occurring visually. The UIButtons located in the UIView can be clicked.I discovered if I remove the UIView four constraints (leading, top, width and height) then scrolling now works visually, but none of the UIButtons are clickable. All weird stuff. Any idea what is going on here?
Dec ’19
Reply to How to send Invite to iPhone using IOS simulator
I had no idea you could use a disconnected iPhone for testing. I thought the iPhone had to be connected to the Mac PC for testing. However, using two iPhones to test "Invite" functionality means I will not be able to see any debug output on the simulator, so I really have no way of confirming the code implementation paths are working properly.I guess I would have to implement some TextView object (as part of my application) for testing purposes on iPhones. The TextView object would be populated with "print" statement output from my application to allow me to see what is going on when testing with real iPhones directly. Is this what people are expected to do?
Dec ’19
Reply to How to assign constraints to a Scrollview which covers part of the screen only?
>>If you set constant at 150, that will not be 2/3 in all cases (e.g., landscape, or iPad).Yes, understood :>) I am just reporting my issue in a general fashion so I try to keep my explanation/summary to a bare minimum so I do not get into the super details of exactly what I am doing, My point is that I do not want to have a ScrollView covering the complete screen. Just assume I am using iPhone 8 in portrait mode and I only want 2/3 of the screen to be scrollable.>>Why do you create a BaseView and put the Scroll inside ?I believe I read a ScrollView must have all of it's constraints (ie: leading, trailing, top and bottom) set to zero(0) for it to work properly. is this true? Assuming this is true, then if I want the Scrollview to cover the complete ViewController screen then this is easy to do and does not involve me creating a BaseView UIVIew, however, since I only want the ScrollView to cover 2/3 of the screen then the only way to have ScrollView constraints all being zero(0) is if I put the ScrollView into a BaseView UIView. Basically, the BaseView UIView covers 2/3 of the screen and the ScrollView is placed inside the BaseView, thus allowing me to set all constraints of the ScrollView to 0.Are you saying I can place a ScrollView object onto the ViewController area and set constraints so the ScrollView only covers 2/3 of the screen?>>Do you get what you expect ? Otherwise, what do you get ?Here is my first main issue simply described:Issue #1I place a BaseView UIView on to the ViewController and set the BaseView constraints so it covers 2/3 of the screen. This works nicely and all constraints are BLUE. I now place a ScrollView inside the BaseView and set the ScrollView cosntraints (ie: leading, trailing, top and bottom) to be zero(0). After this, my issue is that all of the ScrollView constraints are RED. Why are the ScrollView constraints not all BLUE at this point?>> You'd probably better create the ScrollView at top hierarchy level (leading/trailing=0 and top/bottom=150)>> then put the BaseView inside the ScrollView (leading/trailing/top/bottom=0)This would mean the BaseView would be the same exact size of the ScrollView. The objects which I am dealing with cover a 500x500 UIView area, thus I need scrolling capabilities. As a result, I cannot place all of the objects into a UIView which is the same exact size as the ScrollView, as you are suggesting.Issue #2I am using interface builder to place UIViews and ScrollView into my storyboard. The UIView which has all of my objects (buttons, labels, etc.) has a size of 500x500 (for example). This UIView needs to go inside of the ScrollView to allow scrolling to eventually occur. I would like to set various constraints on the objects (buttons, labels, etc.) located within the UIView, however, I cannot set valid BLUE constraints on these objects until I can set valid BLUE constraints for the UIView and for the ScrollView first.
Dec ’19
Reply to Invite players programmatically into a match
Searching for "Go Connect" in the App Store returns the following results for me:Connect by goPanache (Booking Beauty Professional)GOconnect (Lifestyle)GoToConnect (Business)Proximiti GoCONNECT (Business)Word Search - CrosswordGO!CONNECT! (Casual)4FrontGoGo-SIMetc..There is nothin which I can see caleld Go Connect dealing with games
Dec ’19
Reply to How to ensure only one player sets game options in a match
I still need help please I do not think using a player attribute mask in the match request is going to work. If I use a mask to represent i am the host of the game, then I am going to need the three other players to each have a different player attribute mask to represent they will be playing as a non-host: 0xFF000000 = Host player 1 0x00FF0000 = Non-Host player 2 0x0000FF00 = Non-Host player 3 0x000000FF = Non-Host player 4It seems quite non-logical to expect player 2, 3 and 4 to submit different masks to mean the same thing. For a 2 player game I can use two masks and make it work: 0xFFFF0000 = Host player 1 0x0000FFFF = Non-Host player 2however, for 3 player or 4 player games using a player attribute mask falls apart it seemsAny idea how I can ensure only one player is responsible for setting up the game options before the match invites are sent out?
Dec ’19
Reply to What occurs when a player declines an invitation?
I believe I found my answer in the Game Center Programming Guide under "Real Time Matches" (see below),I guess a "match" will be returned after calling "findMatchForRequest" and I can then check whether the "match.expectedPlayerCount == 0" . If not zero then I guess I know some players provided in the "request.recipient" array did not accept the invitation. I can then either invite more friends (ie: call addPlayersToMatch and providing a new request.recipient array) or simply fill in the empty slots with random players (ie: call addPlayersToMatch but do not provide any request.recipient array information)GAME CENTER PROGRAMMING GUIDE (REAL-TIME MATCH)Because some of the invitations may not be accepted, it is possible you may receive a match that still needs more players. With this in mind, your custom user interface should implement the following behavior:The first time the player invites players to join the match, create the match request with those players and call the findMatchForRequest:withCompletionHandler: method. Wait for the match to be returned (or cancel the request if the player cancels the invitations).If the player wants to add more players to the match after the invitations are processed, perform the same procedure again, but call the addPlayersToMatch:matchRequest:completionHandler: method instead.If the player wants to automatch the remaining slots, create a match request but do not include a list of players to invite. Call the addPlayersToMatch:matchRequest:completionHandler: method to fill the remaining slots. You must wait until all invited players have connected as all pending match requests are cancelled when automatching the remaining player slots.If the player wants to start the match with the players already in the match, call the finishMatchmakingForMatch: method to end matchmaking entirely.If you want to create a match that contains both invited players and automatched players, you must first create the match with the invited players. After all invited players have connected, you can then add players through automatching.
Dec ’19
Reply to Invite players programmatically into a match
ok, thanks for your input. I really want to create my own viewcontroller so my interface looks like it is part of my game motif instead of some default Game CEnter interface. However, we will see how it goes 🙂 . There is not a lot of examples using swift 4 so I am trying to read everything and put the pieces of the puzzle together bit by bit.
Dec ’19