SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.3k stars 742 forks source link

Message View Width not adjust according to screenWidth on landscape mode? #391

Closed Lokeshgupta25 closed 4 years ago

Lokeshgupta25 commented 4 years ago

When i change our app mode from portrait to landscape mode swiftmessages width not adjust to full width of screen . How can i solve this?

i am using follwing code...

   var alertConfig = SwiftMessages.defaultConfig
    alertConfig.presentationStyle = .top
    alertConfig.prefersStatusBarHidden = true

    alertConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
    alertConfig.duration = .seconds(seconds: 2.0)
    alertConfig.shouldAutorotate = true
    let alertView = MessageView.viewFromNib(layout: .messageView)
    alertView.button?.isHidden = true
    alertView.configureBackgroundView(width:1000)
    alertView.configureDropShadow()
    alertView.titleLabel?.font = UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular)
    alertView.bodyLabel?.text = message
    alertView.bodyLabel?.font = UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular)
    alertView.configureContent(title: title.rawValue, body: message)

In portrait mode Simulator Screen Shot - iPhone 11 Pro Max - 2020-04-24 at 18 12 23

On in Landscape mode... Simulator Screen Shot - iPhone 11 Pro Max - 2020-04-24 at 18 12 17

wtmoose commented 4 years ago

That isn't normal. I'd remove

alertView.configureBackgroundView(width:1000)

It isn't needed.

Lokeshgupta25 commented 4 years ago

alertView.configureBackgroundView(width:1000) its working same after removing this also

My Singleton class for this.. class Messages : NSObject {

static let shared = Messages()

//MARK: - Show Alert     Problem 
func show(alert title : Alert , message : String , type : Type){

    var alertConfig = SwiftMessages.defaultConfig
    alertConfig.presentationStyle = .top
    alertConfig.prefersStatusBarHidden = true

    alertConfig.presentationContext = .window(windowLevel: UIWindow.Level.statusBar)
    alertConfig.duration = .seconds(seconds: 2.0)
    alertConfig.shouldAutorotate = true
    let alertView = MessageView.viewFromNib(layout: .messageView)
    alertView.button?.isHidden = true
    alertView.configureDropShadow()
    alertView.titleLabel?.font = UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular)
    alertView.bodyLabel?.text = message
    alertView.bodyLabel?.font = UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular)
    alertView.configureContent(title: title.rawValue, body: message)

    alertView.titleLabel?.textColor = UIColor.white
    alertView.bodyLabel?.textColor = UIColor.white

    SwiftMessages.show(config: alertConfig, view: alertView)

}

}

But when i change my app from portrait mode to landscape within in app this alert are not taking complete width of screen on landscape mode.

wtmoose commented 4 years ago

Can you reproduce it in the demo app?

Lokeshgupta25 commented 4 years ago

ya sure

Lokeshgupta25 commented 4 years ago

demo.zip

Please follow the follwing step: App launch on Portrait mode -> click on button for showing Alert -> Change App mode to Landscape -> click on button for showing Alert

wtmoose commented 4 years ago

It works for me. Your environment must be different. I'm using:

Xcode 11.4.1 iPhone 11 Pro simulator

Rotate

Lokeshgupta25 commented 4 years ago

No Please Switch app on landscape mode when portrait mode alert have dismiss.

wtmoose commented 4 years ago

Oh, this is related to the new scene stuff in iOS 13. You need to use the head of the master branch. I have a backlog of fixes to release including the fix for this issue.

Lokeshgupta25 commented 4 years ago

Can you elaborate it more how can I resolve this issue ASAP. Thanks

wtmoose commented 4 years ago

You need to use the head of the master branch.

Lokeshgupta25 commented 4 years ago

have you fixed this issue or you are going to fix this issue?

wtmoose commented 4 years ago

Included in 8.0.0 release